   Java Strings
  i am pretty new to java and so have been trying to make some basic programs that i have already made in c++. problem is that while i can take user input from a user, i can't for the life of me make the string input tests workeg..import java.lang.String;import java.io.*;public class Main{  public static void main(String args[]) throws IOException    {    BufferedReader console = new BufferedReader(new InputStreamReader(System.in));   System.out.println("Please enter your favourite color: ");   String FavColor = console.readLine(); if(FavColor.toLowerCase() == "blue")   {  System.out.println("Go Blue!");   }   else   {   System.out.println("Whatever. I don't really care");   }   // other testing code here   //also try and catch staements would be included    }}if you compile this the 'if' statement never becomes true.what am i doing wrong?   
  Your problem is here: FavColor.toLowerCase() == "blue"In Java, == is for comparing identity (pretty much address in memory), while .equals() is for comparing equality. Your code should be:FavColor.toLowerCase().equals("blue")   ;  Two possiblities comes to mind:1) When you use readLine, does the resulting string contain the eol? So it's not "blue", but "blue\n" (or whatever).2) Java strings are immutable, and == compares objects, not what is contained in the object. Ei. String a = new String("abc");String b = new String("abc");a != bTry using favColor.equalIgnoreCase("blue");  thanks guys. that worked great! now i can finally make some better programs!thanks again.   