函数返回的String值使用equals方法结果false

public class Logpass {
	Connection con;
	public Logpass(){}
	public int getPass() {
		int pass=0;
		try {
			con=new Dbl().getConnection();
			String sql="select pass from P";
			PreparedStatement pstmt=con.prepareStatement(sql);
			ResultSet rs=pstmt.executeQuery();
		while(rs.next()) {
			pass=rs.getInt("pass");
			}		
		} catch (ClassNotFoundException | SQLException e1) {e1.printStackTrace();}
	return pass;
	
	}
	public String getAdmin() {
		String admin="null";
		try {
			con=new Dbl().getConnection();
			String sql="select admin from P";
			PreparedStatement pstmt=con.prepareStatement(sql);
			ResultSet rs=pstmt.executeQuery();
		while(rs.next()) {
			admin=rs.getString("admin");
			}		
		} catch (ClassNotFoundException | SQLException e1) {e1.printStackTrace();}
	return admin;
	}
}

public class test {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Logpass pa=new Logpass();
		if(pa.getAdmin().equals("admin")) {System.out.println("00");}
		else {System.out.println("no\n"+pa.getAdmin());}
	}

}

输出结果:no

                  admin

求教

if(pa.getAdmin().equals("admin")) {System.out.println("00");}

修改一下

if(pa.getAdmin().trim().equals("admin")) {System.out.println("00");}

试试

String admin="null";修改成String admin="";试一下

String admin="null", 没必要加引号,即String admin=null;

在if前面pa.getAdmin().打印出来不就知道了

检查下admin后面是不是带了空格

谢谢大佬们,嘤