๐Ÿผ๋ฐฑ์•ค๋“œ/Java ๋ฌธ๋ฒ•

public class _06_While { public static void main(String[] args) { //๋ฐ˜๋ณต๋ฌธ while //์ˆ˜์˜์žฅ์—์„œ ์ˆ˜์˜์„ ํ•˜๋Š” ๋ชจ์Šต int distance = 25; //์ „์ฒด ๊ฑฐ๋ฆฌ 25 int move = 0; //ํ˜„์žฌ ์ด๋™ ๊ฑฐ๋ฆฌ 0 while(move>distance) {//ํ˜„์žฌ ์ด๋™๊ฑฐ๋ฆฌ๊ฐ€ ์ „์ฒด ๊ฑฐ๋ฆฌ๋ณด๋‹ค ์ž‘๋‹ค๋Š” ์กฐ๊ฑด์ด ์ฐธ์ธ ๋™์•ˆ ๋ฐ˜๋ณต ์ˆ˜ํ–‰ System.out.println("๋ฐœ์ฐจ๊ธฐ๋ฅผ ๊ณ„์† ํ•ฉ๋‹ˆ๋‹ค."+move); } } }
public class _05_For { public static void main(String[] args) { //๋ฐ˜๋ณต๋ฌธ FOR System.out.println("์–ด์„œ์˜ค์„ธ์š”. ๋‚˜์ฝ”์ž…๋‹ˆ๋‹ค"); for (int i =0;i
public class _04_SwitchCase { public static void main(String[] args) { //Switch Case //์„์ฐจ์— ๋”ฐ๋ฅธ ์žฅํ•™๊ธˆ ์ง€๊ธ‰ //1๋“ฑ : ์ „์•ก ์žฅํ•™๊ธˆ //2๋“ฑ : ๋ฐ˜์•ก ์žฅํ•™๊ธˆ //3๋“ฑ : ๋ฐ˜์•ก ์žฅํ•™๊ธˆ //๊ทธ ์™ธ : ์žฅํ•™๊ธˆ ๋Œ€์ƒ ์•„๋‹˜ int ranking = 1; //1๋“ฑ if(ranking == 1){ System.out.println("์ „์•ก ์žฅํ•™๊ธˆ"); }else if (ranking == 2 ){ System.out.println("๋ฐ˜์•ก ์žฅํ•™๊ธˆ"); }else if (ranking == 3 ){ System.out.println("๋ฐ˜์•ก ์žฅํ•™๊ธˆ"); }else{ System.out.println("์žฅํ•™๊ธˆ ๋Œ€์ƒ ์•„๋‹˜"); } System.out.pr..
public class _03_elseif { public static void main(String[] args) { //์กฐ๊ฑด๋ฌธ else if //ํ•œ๋ผ๋ด‰ ์—์ด๋“œ๊ฐ€ ์žˆ์œผ๋ฉด +1 //๋˜๋Š” ๋ง๊ณ  ์ฃผ์Šค๊ฐ€ ์žˆ์œผ๋ฉด +1 //๋˜๋Š” ์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ +1 boolean hallabongAde = true; //ํ•œ๋ผ๋ด‰ ์—์ด๋“œ boolean mangoJuice = true; //๋ง๊ณ  ์ฃผ์Šค if(hallabongAde){ System.out.println("ํ•œ๋ผ๋ด‰ ์—์ด๋“œ +1"); }else if (mangoJuice){ System.out.println("๋ง๊ณ  ์ฃผ์Šค +1"); }else { System.out.println("์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ +1"); } System.out.println("์ปคํ”ผ ์ฃผ์Šค ์™„๋ฃŒ #1"); ..
public class _02_else { public static void main(String[] args) { //์กฐ๊ฑด๋ฌธ if else int hour = 10; if (hour = 14 || morningCoffee == true) { System.out.println("์•„์ด์Šค ์•„..
public class _01_if { public static void main(String[] args) { //์กฐ๊ฑด๋ฌธ If int hour = 15; //์˜คํ›„ 3์‹œ //if ๋ฌธ ๋‚ด์—์„œ ํ•˜๋‚˜์˜ ๋ฌธ์žฅ์„ ์‹คํ–‰ํ•  ๋•Œ๋Š” {} ์ƒ๋žต ๊ฐ€๋Šฅ if(hour < 14) System.out.println("์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ +1"); //if ๋ฌธ ๋‚ด์—์„œ 2๊ฐœ ์ด์ƒ์˜ ๋ฌธ์žฅ์„ ์‹คํ–‰ํ•  ๋•Œ๋Š” {} ์ƒ๋žต ๋ถˆ๊ฐ€ if(hour < 14) { System.out.println("์•„์ด์Šค ์•„๋ฉ”๋ฆฌ์นด๋…ธ +1"); System.out.println("์ƒท ์ถ”๊ฐ€"); } System.out.println(("์ปคํ”ผ ์ฃผ๋ฌธ ์™„๋ฃŒ #1")); //์˜คํ›„ 2์‹œ ์ด์ „, ๋ชจ๋‹ ์ปคํ”ผ๋ฅผ ๋งˆ์‹œ์ง€ ์•Š์€ ๊ฒฝ์šฐ? hour = 10; boolean morningCoffe..
public class _04_EscapeSequence { public static void main(String[] args) { //ํŠน์ˆ˜๋ฌธ์ž, ์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž // \n \t \\ \" \' System.out.println("์ž๋ฐ”๊ฐ€"); System.out.println("๋„ˆ๋ฌด"); System.out.println("์žฌ๋ฐŒ์–ด์š”"); // \n: ์ค„๋ฐ”๊ฟˆ System.out.println("์ž๋ฐ”๊ฐ€\n๋„ˆ๋ฌด\n์žฌ๋ฐŒ์–ด์š”"); // \t: ํƒญ //ํ•ด๋ฌผํŒŒ์ „ 9000์› //๊น€์น˜์ „ 8000์› System.out.println("ํ•ด๋ฌผํŒŒ์ „\t9000์›"); System.out.println("๊น€์น˜์ „\t8000์›"); System.out.println("๋ถ€์ถ”์ „\t8000์›"); // \\: ์—ญ์Šฌ๋ž˜์‹œ System.out..
public class _03_StringCompare { public static void main(String[] args) { //๋ฌธ์ž์—ด ๋น„๊ต String s1 = "Java"; String s2 = "Python"; System.out.println(s1.equals("Java")); //๋ฌธ์ž์—ด ๋‚ด์šฉ์ด ๊ฐ™์œผ๋ฉด true, ๋‹ค๋ฅด๋ฉด false System.out.println(s2.equalsIgnoreCase("python")); //๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ ์—†์ด ๋ฌธ์ž์—ด ๋‚ด์šฉ์ด ๊ฐ™์€์ง€ ์—ฌ๋ถ€ ์ฒดํฌ //๋ฌธ์ž์—ด ๋น„๊ต ์‹ฌํ™” s1 = "1234"; //๋ฒฝ์— ๋ถ™์€ ๋ฉ”๋ชจ์ง€์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ •๋ณด s2 = "1234"; System.out.println(s1.equals(s2)); //true (๋‚ด์šฉ) System.out.print..
๊ณ„๋ž€์†Œ๋…„
'๐Ÿผ๋ฐฑ์•ค๋“œ/Java ๋ฌธ๋ฒ•' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (3 Page)