//package hello; //must be in hello subdir, run: java hello.Hello //import java.util.Date; //deprecated //import java.util.Calendar; import java.util.*; public class Hello { // static boolean not_first_call; // public static void main(String[] args) throws java.io.IOException{ public static void main(String[] args){ //return; //error: remaining code is unreachable /* //random unicode?? outputs ? as single bytes System.out.println('\u01f0'); System.out.println('\u02f0'); System.out.println('\u03f0'); */ /* boolean b = true; System.out.println("b= "+b); System.out.println('\u00f0'); */ //OA parsed first as literal linefeed! cant even be commented! // System.out.println("0A = "+'u000A'); //removed backslash! /* char c; c = 651; System.out.println("c= "+c); int i = 'a'; System.out.println("i= "+i); byte b1 = 120; System.out.println("b1= "+b1); byte b2 = (byte)1000; System.out.println("b2= "+b2); byte b3 = (byte)(b1 * 2); System.out.println("b3= "+b3); */ /* System.out.println("Hello\n World!" +1234/23.0); // / first String s = helloagain("asdfasdf"); System.out.println(s); System.out.println(args.length); */ /* for (int i=0; i2?1:1.3); System.out.println(3>2?'e':1.3); // System.out.println(3>2?true:1); //syntax error */ /* Hello hello_obj = new Hello(); hello_obj.test(); */ /* // double inf = 1/0; double inf = 1./0; double neginf = -1./0; double negzero = -1/inf; double nan = 0./0; System.out.println("inf 1.0/0 = "+inf); System.out.println("neginf -1.0/0 = "+neginf); System.out.println("negzero -1/inf = "+negzero); System.out.println("nan 0./0 = "+nan); System.out.println("sqrt(-1) = "+Math.sqrt(-1)); if (nan == nan) System.out.println("nan is nan"); else System.out.println("nan is not nan"); if (Double.isNaN(nan)) System.out.println("nan is Double.isNan"); System.out.println("inf%2="+(inf%2)); // System.out.println("3%0="+(3%0)); //syntax error System.out.println("-7%2="+(-7%2)); System.out.println("-7%-2="+(-7%-2)); System.out.println("4.3%2.1="+(4.3%2.1)); System.out.println("1-.1="+(1-.1)); */ /* float f1 = 1; //float f2 = 1.0; //syntax error float f3 = 1F; float f4 = 1.0F; float f5 = (float)1.0; */ /* //int i = 0xffffffffffffffff; //integer literal too bit //int i = 0xfffffffff; //9 f's integer literal too big //int i2 = 0xffffffffffffffffL; //loss of precision //long l1 = 0xffffffffffffffff; //integer literal too bit long l2 = 0xffffffffffffffffL; int i = 0xffffffff; */ /* X x = new X(4); System.out.println(x.i); x = new X(); System.out.println(x.i); */ /* X x = new X(); //Xi is 5 Y y = new Y(); //Yi is 7, super's Xi is 5 x.override(); y.override(); System.out.println(x.Xi); //System.out.println(x.Yi); //super doesn't have sub's field System.out.println(y.Xi); System.out.println(y.Yi); x = y; //super = sub System.out.println(x.Xi); //System.out.println(x.Yi); //super doesn't have sub's field, even //if assigned a sub object reference System.out.println(((Y)x).Yi); //casting to sub allows access System.out.println(x.same); //is X's same field System.out.println(((Y)x).same); //is sub Y's same field x.override(); //is sub's overridden method */ /* boolean b=true; char c='a'; if (b == c) //error System.out.println("asdf"); */ /* if (!not_first_call) { not_first_call = true; W w = new W(); w.overridetest(); w.main(new String[]{"whats","up","doc"}); } */ /* X x = new X(); */ /* Y y = new Y(); if (x.equals(y)) System.out.println("asdf"); else System.out.println("difffent type objects are always not equal"); */ /* String s1; String s2=""; if (s2.equals(s1)) //error, not initialized System.out.println("asdf"); else System.out.println("empty string not the same as null"); */ /* Date today = new Date(); System.out.println(today.getMonth()); System.out.println(today.getDay()); System.out.println(today.getYear()); Calendar now = Calendar.getInstance(); System.out.println(now.get(Calendar.MONTH)); */ /* try { System.out.println("hi again inside try"); } catch (Throwable e) { } */ /* String ups = "ABCD"; String s = ups.toUpperCase(); if (ups == s) System.out.println("same refs"); */ /* switch (2) { default: System.out.println("default"); break; case 3: System.out.println("case 3"); break; } */ /* int asdf; System.out.println("value of assignment expression: "+(asdf=5)); */ /* System.out.println(3+4+" hi"); System.out.println("Hi"+3+4); */ /* if ("dog" == "dog") System.out.println("dog == dog"); String d = "dog"; if (d == "dog") //true! System.out.println("d == dog"); String d2 = "dog"; //same object as d's dog? if (d == d2) //true?!?! System.out.println("d == d2"); String d3 = new String("dog"); if (d == d3) //false. new STring object System.out.println("d == d3"); if (d.equals(d2)) //true System.out.println("d equals dog"); if ('a' == 97) System.out.println("a == 97"); //if (5 == true) //syntax error // System.out.println("5 == true"); //if (5 == "dog") //syntax error // System.out.println("5 == dog"); */ /* X x = new X(); if (x instanceof X) System.out.println("x is an X"); if (x instanceof Object) System.out.println("x is an Object"); //if (x instanceof String) //syntax error //System.out.println("x is an String"); */ /* X x = new X(); System.out.println("x.xx= "+x.xx); System.out.println("X.xx= "+X.xx); X x2; //System.out.println("x2.xx= "+x2.xx);//syntax error because x2 uninit */ /* final int a=1; final int b; int arf=0; b = 2; //not a constant, so can't be case value switch (arf) { case a: System.out.println("arf == a"); break; //case b: System.out.println("arf == b"); break; } */ /* //compile with -source 1.4, else syntax erro, thinks is identifier //run with -ea to enable, else ignores //assert (false) : "its false"; assert (false) : 5+11; */ /* int a = 10; int [][] M = new int[a][]; System.out.println("M.lenght="+M.length); for (int i=0; i