I created a document called doc.txt, and in it I wrote "blaha". I wrote a program to see if it says blaha.
File file = new File("C:/Users/Public/doc.txt");
if (file.exists()){
FileReader fr = new FileReader(file);
LineNumberReader ln = new LineNumberReader(fr);
while (ln.getLineNumber() == 0){
String s = ln.readLine();
System.out.println(s);
if(s=="blaha"){
System.out.println("Match");
}else{
System.out.println("Nomatch");
}
}
}
And when I run the program, it always says Nomatch. Why is this?