Why this code doesn't compile on line 7?
public class HelloWorld
{
public static void main(String[] args)
{
String s1 = "java";
StringBuilder s2 = new StringBuilder();
if (s1 == s2)
System.out.print("1");
}
}
and why this is accepted?
public class HelloWorld
{
public static void main(String[] args)
{
String s1 = "java";
Object s2 = new Object();
if (s1 == s2)
System.out.print("1");
}
}
Should not be accepted even StringBuilder? Isn't an Object?