Java 변수일 때와 객체일 때의 적용 차이 function call

별의개발자커비·2023년 2월 12일
0

Java

목록 보기
34/71
post-thumbnail
public class ListDemo5 {
	
	public static void increase(int[] x) {
		x[0]++;
	}


	public static void main(String[] args) {
		int [] number = {10} ;
		
		System.out.println("before function call: " + number[0] );
		increase(number);
		System.out.println("after function call: " + number[0] ); // int number = 10 으로 했을 때는 안바뀐다. --> 이걸 객체로 바꾸면 바뀐다 @@왜?? 이해필

	}

}
profile
비전공자 독학러. 일단 쌔린다. 개발 공부👊

0개의 댓글