[Java] 4. 변수 (배열)

백하림's avatar
Feb 03, 2025
[Java] 4. 변수 (배열)
notion image
package ex01; public class Var03 { public static void main(String[] args) { int[] arr = {2, 4, 6, 8}; System.out.println(arr[2]); arr[1] = 10; // 배열 1번지에 있는 4를 10으로 변경하기 위함. System.out.println(arr[1]); // 배열 1번지에 있는 정수 출력 System.out.println(arr[4]); // 배열 4번지에 있는 정수 출력 그러나 오류. 인덱스 범위를 넘어감. } }
notion image
System.out.println(arr[4]); // 배열 4번지에 있는 정수 출력 그러나 오류. 인덱스 범위를 넘어감.
 
Share article

harimmon