@ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, )
@ vs. logic data method variable Data Data Flow (Type), ( )
@ Member field Method A Method B Method Field (data) Method - (data)
@ if Yes Yes A Yes No (else) if boolean. C if ( 1 ), if ( 0 ) if(true), if(false). No (else) if( a%2==0){ System.out.println( ); else { System.out.println( ); if( avg >90){ System.out.println( A ); else if( avg >80){ System.out.println( B ); else ------ No (else) B ----
@ if, if if( a%2==0){ System.out.println( ); else { System.out.println( ); int a=15; 1) if(a%2==0) 2) else { int avg=73; 1) if( avg > 90) 2) else if { avg > 80 3) else if { avg > 70 4) { print C
@ switch switch( a ){ case 0 : -- ------ switch(a){ case 0: System.out.println( 0 ); break; case 1: System.out.println( 1 ); break; case 2: System.out.println( 2 ); break; default : System.out.println( 3 ); break; switch a primitive type byte, short, char, int. case. ex) case a>90 : ---- (x)
@ switch char ca= a ; switch(ca){ case a : System.out.println( a ); case b : System.out.println( b ); case c : System.out.println( c ); break; default : System.out.println( d ); break; break break byte ba=10; // char cd = ba; (x) // int char cd=(char)ba; //(0) byte cd=10; switch( cd ){ case a : ---- //error
@ for i=0 ; i<9 ++i for( int i=0 ; i< 9 ; i++){ for( ; ; ){ // loop while( true) int i=0; for( ; i<9; ++i ) for( int i=0, j=1 ; j<9; ++j)
@ for i=0 ; i<9 ++i i=0 if(0%2) continue i=1 1<20 else print i=2 2<20 if(2%2) continue i=3 3<20 ----- if(19%2) else print i=20 20<20 end
@ for for( int i=1; i<500;i*=2){ System.out.println(" ==> "+i); for( int i=500; i>0;i-=50){ System.out.println(" <== "+i); for( int i=2; i<500;i=3*i-2){ System.out.println(" A3n_2 "+i);
@ while while( ) int i=0; while( i<9 ){ System.out.println(i+ ); i++; while( ) continue { break while
@ do while while( ) while : while { do while int i=15; do{ i++; System.out.println("i? "+i); while( i<20 ); i=15 i=16 print 16 while(16<20) i=17 print 17 while(17<20) i=18 print 18 while(18<20) i=19 print 19 while(19<20) i=20 print 20 end
@ goto break for(int i=0;i<10;i++){ aa:{ for(int j=0;j<2;j++){ if(i>5){ System.out.println("i : "+i); else break aa; // for // aa: // for i=0 j=0 if( 0>5 ) else break aa; aa: i=1 j=0 if(1>5) else break aa; aa: i=2 j=0 if(2>5) else break aa; ---- aa: i=6 j=0 if(6>5) println( 6 ) j=1 if(6>5) println(6) i=7 j=0 if(7>5) println( 7 ) j=1 if(7>5) println(7) ---
@ keywords in types, byte short int long char float double true false boolean if else switch case default for do while while continue break
@ 1 String sa=args[0]; String sb=args[1]; String sc=args[2]; String sd=args[3]; System.out.println(". 4!! "); System.out.println(" java ArgsTest_3Chap_01 My Name is Hyoeun"); // java ArgsTest_3Chap_01 My Name is Hyoeun System.out.println(sa); System.out.println(sb); System.out.println(sc); System.out.println(sd); java ArgsTest_3Chap_01 My Name is
@ 1- String System.out.println(". 4!! "); System.out.println(" java ArgsTest_3Chap_01 My Name is Hyoeun"); // java ArgsTest_3Chap_01 My Name is Hyoeun for( int i=0 ; i<args.length ; i++ ){ System.out.println( args[i] ); args[0] args[1] args[2] args[3] My Name is DSU
@ System.in
@ System.in public static void main(string[] args) throws java.io.ioexception // read { char c='0'; int i=0; while(true){ c=(char)system.in.read(); // read -> return int i++; System.out.println(c); // ad 2 enter //--> 'a''d''\n''\r' if(i==10){break; enter \n \r. Exception Handling
@ System.in public static void main(string[] args) throws java.io.ioexception // read { char c='0'; while(c!='q'){ do{ c=(char)system.in.read(); // read -> return int System.out.print(c); while(c=='\n' c=='\r'); enter \n \r. Exception Handling
@ JOptionPane String str= javax.swing.joptionpane.showinputdialog(" "); javax.swing.joptionpane.showmessagedialog(null,str); int yesorno= JOptionPane.showConfirmDialog(null, "choose one", "choose one", JOptionPane.YES_NO_OPTION); if(yesorno==joptionpane.yes_option ){ System.out.println("You choose yes option"); else { System.out.println("You choose No option"); javax.swing.joptionpane
@ JOptionPane String str = javax.swing.joptionpane. showinputdialog(" "); javax.swing.joptionpane. showmessagedialog( null, str); javax.swing.joptionpane. JOptionPane.showConfirmDialog( null, "choose one", "Title: choose one", JOptionPane.YES_NO_OPTION);
@ JOptionPane String str= javax.swing.joptionpane.showinputdialog(" "); javax.swing.joptionpane.showmessagedialog(null,str); int yesorno= JOptionPane.showConfirmDialog(null, "choose one", "choose one", JOptionPane.YES_NO_OPTION); if(yesorno==joptionpane.yes_option ){ System.out.println("You choose yes option"); else { System.out.println("You choose No option"); javax.swing.joptionpane
@ System Package Class
@ for execution time for(int i=0;i<1001;i++){ if(i%2==1){ System.out.print(i+" "); for(int i=1;i<1001;i+=2){ System.out.print(i+" "); long times1=system.currenttimemillis(); for(int i=0;i<1001;i++){ switch(i%2){ case 1 : System.out.print(i+" "); break; default : break; long times2=system.currenttimemillis(); System.out.println( times2 - times1);
@ Nested for i=2 ; i<300 ; i++ j=2 ; j<=i ; j++ for(int i=2;i<300;i++){ System.out.print(i+" : 1 "); for(int j=2;j<=i;j++){ if(i%j==0){ System.out.print(j+" "); System.out.println();
@ Nested for i=2 ; i<100 ; i++ j=2 ; j<i ; j++ for(int i=2;i<100;i++){ boolean boolean isp=true; isp=true; for(int j=2;j<i;j++){ if(i%j==0){ if(i%j==0){ isp=false; isp=false; break; break; // else{ else{ isp=true; isp=true; if(isp){ System.out.println(i+" "); else{ System.out.println(i+" ");
@ for if, if else, if else if, switch case for, while, do while break, continue