Jeon Soo Min
[JAVA] ๋ฐฐ์ด์ํ (for, for-each ์ด์ฉ)
1. ๋ฐฐ์ด ํน์ ๋ถ๋ถ ๊น์ง๋ง ์ํ (i ๊ฐ ์กฐ์ ์ ํตํด) //๋ฐฐ์ด์ ์ํ String[] coffees = {"์๋ฉ๋ฆฌ์นด๋
ธ", "์นดํ ๋ชจ์นด", "๋ผ๋ผ", "์นดํธ์น๋
ธ" }; // for ๋ฐ๋ณต๋ฌธ ์ด์ฉ for (int i = 0; i < 4; i++) { System.out.println(coffees[i] + " ํ๋"); } System.out.println("์ฃผ์ธ์."); System.out.println("----------------"); 2. ๋ฐฐ์ด์ ๊ธธ์ด๋ฅผ ์ด์ฉํด ํ๋์ฝ๋ฉ ํผํ๊ธฐ // ๋ฐฐ์ด์ ๊ธธ์ด๋ฅผ ์ด์ฉํ ์ํ ~~.length == ๋ฐฐ์ด์ ๊ธธ์ด for (int i = 0; i < coffees.length; i++) { System.out.println(coffees[i] + " ํ๋"); } Sy..
2023.01.14
Language/Java