๊ธฐ๋ณธ ๊ตฌ์กฐ
public class ์ด๋ฆ { //ํด๋์ค public static int ์ด๋ฆ(๋ฐ๋ ๊ฑฐ){ //๋ฉ์๋ ์คํํ๋ ๊ฑฐ } }
ctrl+shift+o ์ฌ์ฉํ๋ ํด๋์ค ์ํฌํธ ์๋ ๋ฃ๊ธฐ
Scanner ํด๋์ค
scanf ๊ฐ์ ๊ฑฐ ๋์ Scanner๋ฅผ ๋ฑ๋กํด์ค์ ๊ฑฐ๊ธฐ ์๋ ๊ฑฐ ์ฌ์ฉํด์ผ ํจ.
//์ด ์์๋ ๋ฉ์ธ ๋ฉ์๋์์ ํจ Scanner sc = new Scanner(System.in); int num; num = sc.nextInt(); //String(C์์ char) ๊ฐ์ ๊ฒฝ์ฐ sc.next()๋ฅผ ์ฌ์ฉํ๊ณ //floot, boolean ๊ฐ์ ๊ฒฝ์ฐ๋ ์ญ์ sc.nextFloot(), sc.nextBoolean()
for-each
for(int i=0; i<5; i++) System.out.print(arr[i]+" "); System.out.println(); //for-each for(int i: arr) System.out.print(i+" "); System.out.println(); //๋ณ์ ์ ์ธ ์ ํ ๊ฑฐ๋ ํ๋ค๊ณ ์น๊ณ , ์๋์๋ ๋์ผํ ๊ฒฐ๊ณผ๋ฅผ ๋ํ๋
728x90
๋ฐ์ํ
0