// Java // operation (calculation) class operation { public static void main(String[] args) { byte b1=127, b2=-128; // 1 byte short s1=32767, s2=-32768; // 2 byte int i1=2147483647, i2=-2147483647; // 4 byte long l1=900000000000000000L, l2=-90000000L; // 8 byte, ending with "L" float f1=1.e-6f, f2=-1.e-6f; // 4 byte, ending with "F" double d1=1.e-12, d2=-1.e-12; // 8 byte char c1='S', c2='H'; String st1="SH", st2="SJ"; boolean bl1=true, bl2=false; // calculation result converted to double type double calc=b1+s1; System.out.println(); System.out.println("Maximum value for each type"); System.out.println("byte = " +b1); System.out.println("short = " +(s1-b1)); System.out.println("int = " +i1); System.out.println("long = " +(l1%i1)); System.out.println("float = " +f1); System.out.println("double = " +d1); System.out.println("char = " +c1); System.out.println("String = " + st1 + st2); System.out.println("boolean = " + (b1 != b2)); System.out.println((b1>=s1) && (d1==d2)); System.out.println((d1==d2) || (s1>b1)); System.out.println(); System.out.println("b1 + s1 = " +calc + " (double)"); System.out.println(); } }
Feb 5, 2012
[Java] operation (calculation)
Syntax highlighted by http://tohtml.com/java/
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment