๐Ÿผ๋ฐฑ์•ค๋“œ

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..
public class _02_String2 { public static void main(String[] args) { String s = "I like Java and Python and C."; //๋ฌธ์ž์—ด ๋ณ€ํ™˜ System.out.println(s.replace("and",",")); //"and"๋ฅผ ","๋กœ ๋ณ€ํ™˜ System.out.println((s.substring(7))); //์ธ๋ฑ์Šค ๊ธฐ์ค€ 7 ๋ถ€ํ„ฐ ์‹œ์ž‘ (์ด์ „ ๋‚ด์šฉ์€ ์‚ญ์ œ) System.out.println(s.substring(s.indexOf("Java"))); //"Java"๊ฐ€ ์‹œ์ž‘ํ•˜๋Š” ์œ„์น˜๋ถ€ํ„ฐ, "." ์ด ์‹œ์ž‘ํ•˜๋Š” ์œ„์น˜ ๋ฐ”๋กœ ์•ž๊นŒ์ง€ System.out.println(s.substring(s.indexOf("Java"),s.indexO..
import java.util.Locale; public class _01_String1 { public static void main(String[] args) { String s = "I like Java and Python and C."; System.out.println(s); //๋ฌธ์ž์—ด์˜ ๊ธธ์ด System.out.println(s.length()); //29 //๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜ System.out.println(s.toUpperCase()); //๋Œ€๋ฌธ์ž๋กœ System.out.println(s.toLowerCase()); //์†Œ๋ฌธ์ž๋กœ //ํฌํ•จ ๊ด€๊ณ„ System.out.println(s.contains("Java")); //ํฌํ•จ๋œ๋‹ค๋ฉด true System.out.println(s.contains("C..
๊ณ„๋ž€์†Œ๋…„
'๐Ÿผ๋ฐฑ์•ค๋“œ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (9 Page)