I'm reading input from console, but every time i get a different string. E.g. i'm entering "Bob", then checking if it's really "Bob", and it's not. Also, i checked length - they are identical. Am i doing it wrong?
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter username: ");
String username = null;
try {
username = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if(username == "Bob")
System.out.println("yes");
else
System.out.println("not");
System.out.println(username.length());
System.out.println("Bob".length());
}
}