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..