jeudi 9 janvier 2020

Why does this output "False" i really dont understand.. help please [duplicate]

This question already has an answer here:

Why does this output False?

import javax.swing.JLabel;

public class gettext {
    public static void main(String[] args) {
        JLabel User = new JLabel("User");
        String GetTxt = new String(User.getText());
        if (GetTxt == ("User"))
        { 
            System.out.println(GetTxt);
        } 
        else 
        {
            System.out.println("False");
        }       
    }
}

Aucun commentaire:

Enregistrer un commentaire