

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


public class Test { private int i; private static int j = 0; public Test() { i += 2; j += 3; } public String toString() { return (“i: ” + i + “ j: ” + j); } } class TestDriver{ public static void main(String[]args) { System.out.println(new Test()); System.out.println((new Test()).toString()); System.out.println((new Test()).toString()); System.out.println(new Test()); } }
public class Test { public static void main(String[]args) { String s1 = “3456”; String s2 = “13456”; if(s1.compareTo(s2) > 0 ) System.out.println(“s1 is larger than s2”); else System.out.println(“s1 is less than s2”); if(new Integer(s1).compareTo(new Integer(s2)) >
System.out.println(“Integer s1 is larger than Integer s2”); else System.out.println(“Integer s1 is less than Integer s2”); } }
s1 is larger than s Integer s1 is less than Integer s