Eugene Karpenko

Greenhorn
+ Follow
since Jul 16, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Eugene Karpenko

Fields in an interface are implicitly public, static and final.
On the other hand, fields in an abstract class could have any access modifier, could be static or not, and final or not.
public class Test {
public static Test aa() { return null; }
public static int bb() { return 5; }
public static void main(String[] args) {
System.out.print(aa().bb());
}
}
prints out "5".
Why there is no NullPointerException???
public class Test {
public static void main(String[] args) {
Integer i1 = new Integer(7);
Integer i2 = new Integer(7);
if(i1.equals(i2)) System.out.println("Integer, TRUE");
else System.out.println("Integer, FALSE");
String s1 = new String("abc");
String s2 = new String("abc");
if(s1.equals(s2)) System.out.println("String, TRUE");
else System.out.println("String, FALSE");
StringBuffer sb1 = new StringBuffer("abc");
StringBuffer sb2 = new StringBuffer("abc");
if(sb1.equals(sb2)) System.out.println("String Buffer, TRUE");
else System.out.println("String Buffer, FALSE");
}
}
This code prints out:
Integer, TRUE
String, TRUE
String Buffer, FALSE
Anybody have any idea why String Buffer behaves differently?