@ Lesson 2... ( ). ( ).
@ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member
@ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data
@ Program A Loose coupling (Robust) Tight cohesive Program B. (Reusable)
@ Method A Method B Member field Method Field (data) Method B - (data)
@ Identifiers, - Pascal ex) PersonInSchool, - Camel ex) moneyinmypocket, goschool() (,keyword ) $, _ ($ nested class, _ c ).(2,s2) $,_.
@ Type Type Java Primitive Object Wrapper Wrapper class Primitive Object Built-in Simple Type Built-in Floating-point Type Built-in Object Type User-defined Object Type Boolean type
@ premitive bit bit bit bit bit bit bit bit byte char short int long long float double
@ Keywords Keywords abstract float protected boolean for public break future strictfp byte generic return byvalue goto short assert if static case implements super catch import switch char inner synchronized class instanceof this const int throw continue interface throws default long transient do native true double new try else null var extends operator void false outer volatile final package while finally private New keywords assert,grayed words are reserved but not currently in use. Note: Grayed words are reserved but not currently in use. New keywords assert
@ keywords in types, byte short char int long float double boolean true false if else switch case default for do while while continue break
@ variable data (Storage of data) valuea = 5; valueb = 0; valuec = valueb + valuea; valuec? valueb 0 valuea 5 valued = 5; valued = valued + 6; 6 valued 5
@ data? (down) cast double float long int short, char byte promotion
@ data double float long int short, char byte 8 byte 4 byte 8 byte 4 byte 2 byte 320 0.32E3, 0.00032 0.32E-3 +-4.9E-324 ~.8E308 +-.4E-0.5 ~ 3.4E038-2^63 ~ 2^63 - -2^3 ~ 2^3 - -2^5 ~ 2^5, 0 ~ 2^6 (65536) -2^7 ~ 2^7 int 23 int 23 2048 024 52 256 28 64 32 6 8 4 2 0 00000000 00000000 00000000 00 short 23 00000000 00
@ data ( ) { { int d = 98; int c = 9; { int b = 0; { int a = 0; } } } } { }, { }, //
@ if, for Yes No (else) if( a%2==0){ System.out.println( ); }else { System.out.println( ); } i=0 i<9 for( int i=0 ; i< 9 ; i++){ } i= { },. i=0 0<9 { } i= <9 { } i=2, 9<9 end
@ - int to char casting public class IntToChar{ } public static void main(string[] args) { } for(int i=2;i<=30;i++){ } System.out.print( (char)i+" "); if(i%0==0){ } System.out.println();
@ Unicode 0 ~ 65536 // 50000 char cc=' '; System.out.println((int)cc); //54620 for(int i=540;i<=55400;i++){ } System.out.print( (char)i+" "); if(i%0==0){ System.out.println(); }
@ int, double byte ba=0; byte bb=20; byte bc=0+20; byte bd=ba+bb; System.out.println(ba); System.out.println(bb); System.out.println(bc); System.out.println(bd); //error int ia=20; int ib=30; long la=40l; long lb=50l; float fa=45.0f; float fb=46.67f; double da=4.5; int ic=(int)(la+lb); float fc=ia+ib; double db=fa+ia;
@ Literal
@ Literal
@ Literal System.out.println("Hello\nMy name is Kildong Hong."); //Hello //My name is. // System.out.println("My Uncles\' book"); //My Uncles' book System.out.println("Hucks\b high."); //Huck high. System.out.println(" (\\) 4."); // (\) 4. System.out.println(" \"."); // ". System.out.println(0xFA); //250 6 System.out.println(0222); //46 8
@ Comment ( )
@ ( ) + -- * // % 45+34 = 79 45-34 = 45*34 = 530 45/34 45%34 x = x + 25; x += 25; x = x - 25; x -= 25; x = x * 25; x *= 25; x = x / 25; x /= 25; x = x % 25; x %= 25; x = x + ; x += ; x ++; ++x;
@ (, ) ==!= < > <= >= & ^ &&!, && short circuit. & vs. && vs.
@ Short-Circuit Test int ca=0, cb=20, cc=-30, cd=5, temp=23; if((temp>ca) (temp=='c')){ System.out.println("!!"); } if((temp>ca) (temp=='c')){ System.out.println(" 2!!"); } if((temp<ca)&(temp=='c')){ System.out.println(" 3!!"); } if((temp<ca)&&(temp=='c')){ System.out.println(" 4!!"); }
@ Logical Operate Test boolean boa=true, boa2=false, bob=true, bob2=false; System.out.println("P Q P&Q P^Q!P"); System.out.print((boa boa)+" "+(boa&boa)+" "+(boa^boa)+" "+(!boa)+"\n"); System.out.print((boa boa2)+" "+(boa&boa2)+" "+(boa^boa2)+" "+(!boa)+"\n"); System.out.print((boa2 boa)+" "+(boa2&boa)+" "+(boa2^boa)+" "+(!boa2)+"\n"); System.out.print((boa2 boa2)+" "+(boa2&boa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 0
@ bit shift >> 65>>3=8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 shift << 65<<3=520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
@ bit shift >> -65>>3=-9 0 0 0 0 0 0 0 shift >>> -65>>>3=536870903 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
@ ( {}, tab ) Short circuit
@ (Tab) space.,...... main (override). 30. continue break. final private.
@
@
@ :: If else
@ :: switch case
@ :: while
@ :: do while
@ :: for
@ :: break, continue, return
@ :: break, continue, return
@ :: break, continue, return
@. ) 00,.