Skip to content

Latest commit

ย 

History

History
486 lines (339 loc) ยท 11.3 KB

File metadata and controls

486 lines (339 loc) ยท 11.3 KB
icon
java

์ž๋ฐ” ๋ฌธ๋ฒ• ํ•œ๋ˆˆ์— ์ •๋ฆฌ 1ํŽธ

์ž๋ฐ”๋Š” ํ•™๊ต์—์„œ ๋งŽ์ด ๋ฐฐ์› ์ง€๋งŒ ๋ญ”๊ฐ€ ํ•œ๋ฒˆ์— ์ •๋ฆฌ๊ฐ€ ์•ˆ๋œ ๋Š๋‚Œ์ด๋ผ ์ฝ”๋”ฉ์‹œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ฌธ๋ฒ•์— ํ•œ ํ•ด ์ •๋ฆฌํ•ด๋ณด๊ณ ์ž ํ•จ

main


main ๋ฉ”์„œ๋“œ์—์„œ ์ œ์ผ ๋จผ์ € ์‹œ์ž‘

public class Main{
	public class void main(String[] args){

	}
}

println


  • ๊ฒฐ๊ณผ๊ฐ’์„ ๋‚ด์ฃผ๋Š” ํ•จ์ˆ˜, ๋ฌธ์ž์—ด, ์ˆซ์ž, ์ˆ˜์‹, ๋ณ€์ˆ˜, ๋ณ€์ˆ˜์— ์ˆ˜์‹๋„ ์‚ฌ์šฉ ๊ฐ€๋Šฅ
  • ์ฐธ๊ณ ๋กœ ๋ณ€์ˆ˜๋Š” ๊ฐ’์„ ์ง€์ •ํ•˜๊ณ  ๋‹ค์‹œ ๊ฐฑ์‹  ๊ฐ€๋Šฅ
public class Main{

	public class void main(String[] args){
		int x =30; //๋ณ€์ˆ˜
		System.out.println("Hello World"); //๋ฌธ์ž์—ด 
		System.out.println(35 + 30); //์ˆ˜์‹
		System.out.println(x + 30); //๋ณ€์ˆ˜์˜ ์ˆ˜์‹

		x = 40;
		System.out.println(x); // x ๊ฐ’์€ ์œ„์™€ ์ƒ๊ด€์—†์ด 40์œผ๋กœ ์ดˆ๊ธฐํ™” 
	}
}

final


๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๊ธฐ ์‹ซ์„ ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ, ์ƒ์ˆ˜

public class Main{

	public class void main(String[] args){
		final int y = 30;
		y = 40; //์—๋Ÿฌ๊ฐ€ ๋œจ๊ฒŒ ๋จ
	}
}

๋ฐ์ดํ„ฐ ํƒ€์ž… + ๋ฆฌํ„ฐ๋Ÿด


public class Main{

	public class void main(String[] args){
		int x = 30; 
		long l = 30L; //int๋ณด๋‹ค ๋” ํฐ ์ˆซ์ž๋ฅผ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•จ, ๋’ค์— ์‹œํ˜ธ๋ฅผ ๋ถ™์—ฌ์คŒ
		short s = 30; //int๋ณด๋‹ค ์ž‘์€ ์ˆซ์ž
		byte b = 30; //short๋ณด๋‹ค ๋” ์ž‘์€ ์ˆซ์ž
		
		//์‹ค์ˆ˜
		double dd = 30.0; //double์ด float๋ณด๋‹ค ๋” ๋„“์€ ๋ฒ”์œ„์˜ ์‹ค์ˆ˜๋ฅผ ๋‹ด์„ ์ˆ˜ ์žˆ์Œ 
		float ff = 30.0f; 

		//์ฐธ, ๊ฑฐ์ง“(if๋ฌธ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ)
		boolean isMarred = ture;
		isMarried = false;

		//๋ฌธ์ž์—ด
		char c ='a' //ํ•œ๊ธ€์ž๋งŒ
		char cc = 'ํ•œ' 

		//๋ฌธ์ž์—ด ์—ฌ๋Ÿฌ๊ฐœ,์ฃผ๋กœ ์‚ฌ์šฉ
		String str = "์—ฌ๋Ÿฌ, ๊ธ€์ž"
		
		
		System.out.println(x);
	}
}

์ž๋™ ํ˜•๋ณ€ํ™˜(๊ฐ•์ œ, ์ž๋™)


public class Main{

	public class void main(String[] args){
		int x = 30; 
		long l = 30L; //int๋ณด๋‹ค ๋” ํฐ ์ˆซ์ž๋ฅผ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•จ, ๋’ค์— ์‹œํ˜ธ๋ฅผ ๋ถ™์—ฌ์คŒ
		short s = 30; //int๋ณด๋‹ค ์ž‘์€ ์ˆซ์ž
		byte b = 30; //short๋ณด๋‹ค ๋” ์ž‘์€ ์ˆซ์ž

		int i = (int)30L; //์˜ค๋ฅธ์ชฝ์— ์žˆ๋Š” long์ด ๋” ํฌ๊ธฐ ๋•Œ๋ฌธ์— **๊ฐ•์ œํ˜• ๋ณ€ํ™˜**(int)๋ฅผ ์•ž์— ๋„ฃ์–ด์คŒ 
		long ll = 30; //์ž‘์€ ๊ฐ’์ด ํฐ ์ƒ์ž์— ๋“ค์–ด๊ฐ , **์ž๋™ํ˜•๋ณ€ํ™˜**

		//์‹ค์ˆ˜
		double dd = 30.0; //double์ด float๋ณด๋‹ค ๋” ๋„“์€ ๋ฒ”์œ„์˜ ์‹ค์ˆ˜๋ฅผ ๋‹ด์„ ์ˆ˜ ์žˆ์Œ 
		float ff = 30.0f; 

		
		dd = ff; //์ž๋™ํ˜•๋ณ€ํ™˜
		ff = (float) dd; //๊ฐ•์ œ ์บ์ŠคํŒ…ํ•˜์—ฌ ํ˜•๋ณ€ํ™˜**[ํฐ ํƒ€์ž…์ด ์ž‘์€ ํƒ€์ž…์— ๋“ค์–ด๊ฐˆ ๋•Œ]**

		//์ฐธ, ๊ฑฐ์ง“(if๋ฌธ์—์„œ ์ฃผ๋กœ ์‚ฌ์šฉ)
		boolean isMarred = ture;
		isMarried = false;

		//๋ฌธ์ž์—ด
		char c ='a'; //ํ•œ๊ธ€์ž๋งŒ
		char cc = 'ํ•œ'; 

		//๋ฌธ์ž์—ด ์—ฌ๋Ÿฌ๊ฐœ,์ฃผ๋กœ ์‚ฌ์šฉ
		String str = "์—ฌ๋Ÿฌ ๊ธ€์ž";
		

	}
}

๋ฌธ์ž์—ด ํฌ๋งท


public class Main{

	public class void main(String[] args){

		//๋ฌธ์ž์—ด ์—ฌ๋Ÿฌ๊ฐœ,์ฃผ๋กœ ์‚ฌ์šฉ
		String str = "์—ฌ๋Ÿฌ ๊ธ€์ž";
		

		System.out.printf("์ €๋Š” %s์ž…๋‹ˆ๋‹ค. ๋‚˜์ด๋Š” %d์‚ด์ด๊ณ ์š”, ํ‚ค๋Š” %fcm์ž…๋‹ˆ๋‹ค.\\n","ํ™๊ธธ๋™", 20, 180.5f); //๋’ค์— ์ธ์ž๋ฅผ ๋„ฃ์–ด์คŒ
	
		String str2 = String.format("์ €๋Š” %s์ž…๋‹ˆ๋‹ค. ๋‚˜์ด๋Š” %d์‚ด์ด๊ณ ์š”, ํ‚ค๋Š” %fcm์ž…๋‹ˆ๋‹ค.","ํ™๊ธธ๋™", 20, 180.5f);
		System.out.println(str2);
		
	}
}

Math


public class Main{

	public class void main(String[] args){

		System.out.println(Math.max(10,30)); //ํฐ ์ˆ˜ ์ถœ๋ ฅ 30
		System.out.println(Math.min(10,30)); //์ž‘์€ ์ˆ˜ ์ถœ๋ ฅ 10
		System.out.println(Math.min(-30)); //์ ˆ๋Œ€๊ฐ’ ์ถœ๋ ฅ 30
	}
}

๋ฌธ์ž์—ด ์ˆซ์ž ์ƒํ˜ธ ๋ณ€ํ™˜


public class Main{

	public class void main(String[] args){

		String str = "100";
		int i = Integer.parseInt(str); //์ˆซ์ž๋กœ ๋ณ€ํ™˜ ์ถœ๋ ฅ์‹œ 100
		long l = Long.parseLong(str); //long์œผ๋กœ ๋ณ€ํ™˜ ์ถœ๋ ฅ์‹œ 100
			
		String str2 = String.valueOf(i); //์ˆซ์ž๋ฅผ ๋‹ค์‹œ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ "100"
		
		System.out.println(i);	
		System.out.println(str2);
	}
}

Random


public class Main {

    public static void main(String[] args) {
	 Random random = new Random();
     int rand = random.nextInt(10); //10๊นŒ์ง€ ์ค‘ ํ•˜๋‚˜๋ฅผ ๋žœ๋ค

    // 0 ~ 9 => 5 ~14
    // 5 ~ 9 4๊ฐœ ์ค‘ ํ•˜๋‚˜๋ฅผ ๋žœ๋ค์œผ๋กœ ๋ฝ‘๊ณ  ์‹ถ์–ด

    int randd = random.nextInt(4)+5; //5~9

     System.out.println(rand);
     System.out.println(randd); 
    }
}

ํ‚ค๋ณด๋“œ ์ž…๋ ฅ


๋ฌธ์ž์—ด ์ž…๋ ฅ์„ ๋ฐ›๋Š” ๊ฒฝ์šฐ, ์ž๋ฐ”๋ฅผ ๊ฐ€์ง€๊ณ  ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ํ‘ผ๋‹ค๋Š” ๋“ฑ

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String str = scanner.next(); //๋ฌธ์ž์—ด
        int i = scanner.nextInt(); //์ˆซ์ž
        long l = scanner.nextLong(); //long

        System.out.println(scanner.next()); //string์„ ๋ฐ›๊ฒ ๋‹ค. ๋ฌธ์ž์—ด์„ ์ž…๋ ฅ์„ ์น˜๋ฉด ์ถœ๋ ฅ
    }
}

If ๋ฌธ


public class Main {
    public static void main(String[] args) {
        int i = 4;

        if(i<3){ //3๋ณด๋‹ค ์ž‘์€ ์ˆ˜
            System.out.println("์ฐธ");
        } else if (i<5) { //3์ด์ƒ 5๋ฏธ๋งŒ
            System.out.println("๊ฑฐ์ง“");
        } else{ // 5์ด์ƒ
            System.out.println("๋‚˜๋จธ์ง€");
        }
    }
}

์‚ผํ•ญ์—ฐ์‚ฐ


public class Main {
    public static void main(String[] args) {
        boolean isMarred = true;

        String str; //๊ฒฐํ˜ผ์„ ํ–ˆ๋‹ค ์•ˆํ–ˆ๋‹ค ๋ผ๋Š” ๋ฌธ์ž๋ฅผ ๋‹ด์Œ

        str = isMarred? "๊ฒฐํ˜ผํ–ˆ๋‹ค" : "๊ฒฐํ˜ผ์„ ์•ˆ ํ–ˆ๋‹ค"; // **str = ์กฐ๊ฑด?์ฐธ:๊ฑฐ์ง“**
        
        System.out.println(str); //๊ฒฐํ˜ผํ–ˆ๋‹ค
    }
}

์œ„์˜ ์‚ผํ•ญ ์—ฐ์‚ฐ์„ if๋ฌธ์œผ๋กœ ๋‚˜ํƒ€๋‚ด์ž๋ฉด

public static void main(String[] args) {
        boolean isMarred = true;

        String str; //๊ฒฐํ˜ผ์„ ํ–ˆ๋‹ค ์•ˆํ–ˆ๋‹ค ๋ผ๋Š” ๋ฌธ์ž๋ฅผ ๋‹ด์Œ

        if(isMarred){
            str = "๊ฒฐํ˜ผ ํ–ˆ๋‹ค";
        } else {
            str = "๊ฒฐํ˜ผ ์•ˆ ํ–ˆ๋‹ค";
        }

        System.out.println(str); //๊ฒฐํ˜ผํ–ˆ๋‹ค
    }

๋…ผ๋ฆฌ์—ฐ์‚ฐ, ๋ถ€์ •์—ฐ์‚ฐ


AND, OR, NOT

isMarred && isMan //AND ๋‘˜ ๋‹ค ๋งž์•„์•ผ ํ•จ

isMarred || isMan // OR ๋‘˜ ์ค‘ ํ•˜๋‚˜

isMarred || !isMan // !์„ ์•ž์— ๋ถ™์ด๋ฉด NOT ์ฐธ์ด ๊ฑฐ์ง“์ด ๋˜๊ณ  ๊ฑฐ์ง“์ด ์ฐธ์ด ๋จ

Switch ๋ฌธ


public class Main {
    public static void main(String[] args) {
       
        String str; //๊ฒฐํ˜ผ์„ ํ–ˆ๋‹ค ์•ˆํ–ˆ๋‹ค ๋ผ๋Š” ๋ฌธ์ž๋ฅผ ๋‹ด์Œ
        
        switch (str){ //boolean์€ ์กฐ๊ฑด์œผ๋กœ ๋“ค์–ด๊ฐ€์ง€ ๋ชปํ•จ switch(์กฐ๊ฑด)
            case "๊ฒฐํ˜ผ ํ–ˆ๋‹ค" : // case ___ :
                System.out.println("O"); //์ถœ๋ ฅ
                break; //break๋ฅผ ์•ˆ์“ฐ๋ฉด ์“ฑ ๋น ์ ธ๋‚˜์˜ด ๊ผญ
            case "๊ฒฐํ˜ผ ์•ˆ ํ–ˆ๋‹ค" :
                System.out.println("X");
                break;
            default: //๋งˆ์ง€๋ง‰์— default
                System.out.println("?");
        }

        System.out.println(str); 
    }
}

๋ฐ˜๋ณต๋ฌธ - For ๋ฌธ


๋ฐ˜๋ณต๋ฌธ์ด ํ•„์š”ํ•œ ์ด์œ 

๋ฐ˜๋ณต๋ฌธ์€ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์š”์†Œ ์ค‘์˜ ํ•˜๋‚˜๋‹ค. ์ธ๊ฐ„์€ ๋ฐ˜๋ณต์ ์ธ ์ž‘์—…์„ ํ• ๋•Œ ์‹ค์ˆ˜ํ•˜๊ณ  ์ง€๋ฃจํ•ดํ•œ๋‹ค. ๊ทธ๊ฒƒ์€ ์‹ค์ˆ˜๋กœ ์ด์–ด์ง„๋‹ค. ์ปดํ“จํ„ฐ๋Š” ์ด๋Ÿฐ ๋ฐ˜๋ณต์ ์ธ ์ž‘์—…์„ ๋Œ€ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋งŒ๋“ค์–ด์ง„ ๊ธฐ๊ณ„๋‹ค. ๋ฐ˜๋ณต๋ฌธ์€ ์ปดํ“จํ„ฐ์—๊ฒŒ ๋ฐ˜๋ณต์ ์ธ ์ž‘์—…์„ ์ง€์‹œํ•˜๋Š” ๋ฐฉ๋ฒ•

for(int i =0; i<10; i++){ 
//for(์ดˆ๊ธฐํ™”; ๋ณ€์ˆ˜์˜ ์กฐ๊ฑด; ๋ธ”๋Ÿญ์„ ํ•œ ๋ฒˆ ์‹คํ–‰ ํ›„ ์–ด๋–ป๊ฒŒ ๋ณ€ํ™”ํ•  ๊ฒƒ์ธ์ง€)
          System.out.println(i);
      }

While ๋ฌธ


int i =0; //์ดˆ๊ธฐํ™”
      while (i<10){ //while(์กฐ๊ฑด๋ฌธ)
          System.out.println(i);
          i++;
      }

Do-While๋ฌธ


int i=0; //์ดˆ๊ธฐํ™”
      do{
          System.out.println(i);
          i++;
      }while(i<10); //while(์กฐ๊ฑด) ๋ฌด์กฐ๊ฑด 1๋ฒˆ์€ ์‹คํ–‰ํ•จ

Break๋ฌธ


๋ฉˆ์ถ”๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉ

public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) { //for(์ดˆ๊ธฐํ™”; ๋ณ€์ˆ˜์˜ ์กฐ๊ฑด; ๋ธ”๋Ÿญ์„ ํ•œ ๋ฒˆ ์‹คํ–‰ ํ›„ ์–ด๋–ป๊ฒŒ ๋ณ€ํ™”ํ•  ๊ฒƒ์ธ์ง€)
            System.out.println(i);
            if(i == 6){
                break; //**6์„ ๋งŒ๋‚˜๋ฉด for๋ฌธ์ด ๋ฉˆ์ถค**
            }
        }

    }

Countinue๋ฌธ


public class Main {
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) { //for(์ดˆ๊ธฐํ™”; ๋ณ€์ˆ˜์˜ ์กฐ๊ฑด; ๋ธ”๋Ÿญ์„ ํ•œ ๋ฒˆ ์‹คํ–‰ ํ›„ ์–ด๋–ป๊ฒŒ ๋ณ€ํ™”ํ•  ๊ฒƒ์ธ์ง€)
            System.out.println(i);
            if(i == 6){
                continue; //**6๋งŒ ๋นผ๊ณ  ์ถœ๋ ฅ๋จ** if๋ฌธ์˜ ์กฐ๊ฑด๋งŒ ๋นผ๊ณ  ์ถœ๋ ฅํ•ด๋ผ
            }
        }

    }
}

๋ฐฐ์—ด ๋ฐ ์˜ˆ์™ธ


๋˜‘๊ฐ™์€ ํƒ€์ž…์˜ ๋ณ€์ˆ˜๋ฅผ ์—ฌ๋Ÿฌ๊ฐœ ๊ฐ€์ ธ์•ผ ํ•  ๋•Œ ์œ ์šฉํ•จ

public class Main {
    public static void main(String[] args) { //๋ฐฐ์—ด์€ ์›๋ž˜ ์ดˆ๊ธฐํ™”๊ฐ€ ๋ชจ๋‘ 0์œผ๋กœ ๋˜์–ด์žˆ์Œ
        int[] score = new int[]{10,20,30,40,50}; //์ดˆ๊ธฐํ™”์™€ ๊ฐ™์ด ์„ ์–ธ๋„, 5๊ฐœ์˜ ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง, ๋ณ€์ˆ˜ ๊ฐ’์„ ๋„ฃ์–ด์คŒ
        int count = score.length; //length : ๋ฐฐ์—ด์˜ ๊ธธ์ด๋ฅผ ์•Œ๋ ค์คŒ
        System.out.println(count); //5๊ฐ€ ์ถœ๋ ฅ
        
        System.out.println(score[0]); //์ถœ๋ ฅ๊ฐ’ 10
    }
}
int[] score = new int[5]; //5๊ฐœ์˜ ๋ณ€์ˆ˜๋ฅผ ๊ฐ€์ง

int[] score = {10, 20, 30, 40, 50} //= int[] score = new int[]{10,20,30,40,50};

์ธ๋ฑ์Šค๋Š” 1๋ถ€ํ„ฐ๊ฐ€ ์•„๋‹Œ 0๋ถ€ํ„ฐ ์ด๋‹ค. ์ฆ‰, 10์€ ์ธ๋ฑ์Šค 0 20์€ ์ธ๋ฑ์Šค 1 ์ด๋Ÿฐ์‹์ด๋‹ค. ๋ณ€์ˆ˜์˜ ๊ฐœ์ˆ˜ - 1์ด ์ตœ์ข… ์ธ๋ฑ์Šค ๋ฒˆํ˜ธ

System.out.println(score[score.length -1 ]);

null๊ณผ NullPointerException


NullPointerException์˜ ๊ฒฝ์šฐ, null์ธ ๊ฐ’์„ ์ฐธ์กฐ์‹œ ๋œจ๋Š” ์—๋Ÿฌ

public class Main {
    public static void main(String[] args) { //๋ฐฐ์—ด์€ ์›๋ž˜ ์ดˆ๊ธฐํ™”๊ฐ€ ๋ชจ๋‘ 0์œผ๋กœ ๋˜์–ด์žˆ์Œ

        String[] names = new String[2];

        System.out.println(names[0]); //๋ณ€์ˆ˜์˜ ๊ฐ’์„ ๋„ฃ์–ด์ฃผ์ง€ ์•Š์•„ ๋ฌธ์ž์—ด์€ null์ด ๋œธ
        System.out.println(names[0].length()); //nullPointerExcepion์ด๋ผ๋Š” ์—๋Ÿฌ๊ฐ€ ๋œธ

    }
}

ArrayList


  • ์ž๋ฐ”์˜ List ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ƒ์†๋ฐ›์€ ์—ฌ๋Ÿฌ ํด๋ž˜์Šค ์ค‘ ํ•˜๋‚˜
  • ์ผ๋ฐ˜ ๋ฐฐ์—ด๊ณผ ๋™์ผํ•˜๊ฒŒ ์—ฐ์†๋œ ๋ฉ”๋ชจ๋ฆฌ ๊ณต๊ฐ„์„ ์‚ฌ์šฉ
  • ๋ฐฐ์—ด๊ณผ์˜ ์ฐจ์ด์ ์€ ๋ฐฐ์—ด์ด ํฌ๊ธฐ๊ฐ€ ๊ณ ์ •์ธ ๋ฐ˜๋ฉด ArrayList๋Š” ํฌ๊ธฐ๊ฐ€ ๊ฐ€๋ณ€์ ์œผ๋กœ ๋ณ€ํ™”ํ•จ
  • ์‚ฌ์šฉ ์ด์œ  : ์ค‘๊ฐ„์— ๊ฐ’์„ ๋ณ€๋™ํ•˜๊ธฐ๊ฐ€ ์‰ฝ๋‹ค.
  • ๋‚ด๋ถ€์ ์œผ๋กœ ์ €์žฅ์ด ๊ฐ€๋Šฅํ•œ ๋ฉ”๋ชจ๋ฆฌ ์šฉ๋Ÿ‰(Capacity)์ด ์žˆ์œผ๋ฉฐ ํ˜„์žฌ ์‚ฌ์šฉ ์ค‘์ธ ๊ณต๊ฐ„์˜ ํฌ๊ธฐ(Size)๊ฐ€ ์žˆ๋‹ค.
  • ๋งŒ์•ฝ ํ˜„์žฌ ๊ฐ€์šฉ๋Ÿ‰(Capacity) ์ด์ƒ์„ ์ €์žฅํ•˜๋ ค๊ณ  ํ•  ๋•Œ ๋” ํฐ ๊ณต๊ฐ„์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์ƒˆ๋กญ๊ฒŒ ํ• ๋‹นํ•œ๋‹ค.
public class Main {
    public static void main(String[] args) { //๋ฐฐ์—ด์€ ์›๋ž˜ ์ดˆ๊ธฐํ™”๊ฐ€ ๋ชจ๋‘ 0์œผ๋กœ ๋˜์–ด์žˆ์Œ

        ArrayList<Integer> scoreList = new ArrayList<>(); //ํƒ€์ž… ์ง€์ •
        scoreList.add(10); //๋ณ€์ˆ˜์˜ ๊ฐ’์„ ๋„ฃ์–ด์คŒ
        scoreList.add(20);
        scoreList.add(30);
        scoreList.add(40);
        scoreList.add(50);

        scoreList.add(2,200); //2๋ฒˆ์งธ ์ธ๋ฑ์Šค์— 200์œผ๋กœ ๋ฐ”๊พธ๊ณ  ์‹ถ๋‹ค๋‹ค
        scoreList.remove(2); // ๊ทธ ์ „์— ์žˆ๋˜ ๊ฐ’์„ ๋บ€๋‹ค. remove

        System.out.println(scoreList.size()); //arrayList์˜ ํฌ๊ธฐ 5
        System.out.println(scoreList.get(3)); // ์ธ๋ฑ์Šค ์‚ฌ์šฉ

    }
}