JAVA/배열

array.java

별초롱언니 2025. 5. 2. 17:44
package test;

import java.util.Scanner;

public class test01 {

	public static void main(String[] args) 
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("배열의 갯수를 입력해주세요!");
        int count = sc.nextInt();

        int[] a = new int[count];

        //배열입력 for
        for(int i=0;i<a.length;i++) {
            System.out.println(i+"번째의 값을 입력해주세요!");
            a[i] = sc.nextInt();
        }
        //배열 출력 for
        for(int i=0; i<a.length;i++) {
            System.out.println("저장된 값은:"+a[i]);
        }

    }

}

'JAVA > 배열' 카테고리의 다른 글

sort  (0) 2025.05.02
lotto.java  (0) 2025.05.02
배열  (0) 2025.05.02