when i compile the code below it shows that the (string) username and myList.get(0) are equal to but the equals function returning false why same also happen for password .
btnLogIn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e) {
String Username=(String) textField.getText(); //fatch the user name from text field
String Password=(String) textField_1.getText(); //fatch password frof text field
databaseconnection connect = new databaseconnection(); // databaseconnection class object to connect to data base
ArrayList myList = connect.search(Username,Password); //serch the username and password in data base
System.out.println((String)myList.get(0)); //for testing
System.out.println((String)myList.get(1)); //for testing
System.out.println(Username); //for testing
System.out.println(Password); //for testing
System.out.println(Username.equals(myList.get(0))); //for testing
System.out.println(Password.equals((String)myList.get(1))); //for testing
if(Username.equals(myList.get(0))&&Password.equals((String)myList.get(1))){
System.out.println("Hello"+Username);
}
}
});

this is my databaseconnection class
import java.sql.*;
import java.util.ArrayList;
public class databaseconnection{
Statement stmt ;
ResultSet rs ;
Connection conn;
ArrayList<String> temp = new ArrayList<String>();
public void getconnection(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:Database1","","");
stmt = conn.createStatement();
}
catch(Exception e){
System.out.println("connection error");
}
}
public ArrayList search(String Username,String Password){
getconnection();
try{
rs = stmt.executeQuery("select username,password from login where username = \'"+Username+"\'");
if(rs.next()){
String tempString=rs.getString("username");
temp.add(tempString);
tempString= rs.getString("password");
temp.add(tempString);
}
}
catch(Exception e){
System.out.println("search error");
}
return temp;
}
}