자바 매개 변수 전달 실현 코드 및 프로 세 스 도해

실행 결과

과정 분석
1.초기 에 스 택 에 main 방법 과 change 방법 이 있 었 고 main 방법 에서 각 요 소 를 초기 화 했 습 니 다.

2.그 후에 change 방법 을 실 행 했 고 실제 인삼 값 은 형 삼 에 전달 되 었 다.

3.change 방법 에서 관련 조작 을 했다.

4.main 에서 각 요소 의 값 을 봅 니 다.
i 는 1 이 고 str 는 hello 이 며 b 는 200 이 고 arr[0]은 2 이 며 my.a 는 11 이다.

*위의 코드 는 다음 과 같 습 니 다.
package cn.yang37.zother.example;
import java.lang.reflect.Array;
import java.util.Arrays;
/**
* @Author Yiang37
* @Date 2020/4/9 21:42
* Description:
*
*/
public class ParameterPassing {
public static void main(String[] args) {
int i = 1;
String str = "yang";
Integer num = 200;
int[] arr = {1, 2, 3, 4, 5};
MyData my = new MyData();
change(i, str, num, arr, my);
System.out.println(i);
System.out.println(str);
System.out.println(num);
System.out.println(Arrays.toString(arr));
System.out.println(my.a);
}
public static void change(int j, String s, Integer n, int[] a, MyData m) {
j += 1;
s += "world";
n += 1;
a[0] += 1;
m.a += 1;
}
}
class MyData {
int a = 10;
}
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
JPA + QueryDSL 계층형 댓글, 대댓글 구현(2)이번엔 전편에 이어서 계층형 댓글, 대댓글을 다시 리팩토링해볼 예정이다. 이전 게시글에서는 계층형 댓글, 대댓글을 구현은 되었지만 N+1 문제가 있었다. 이번에는 그 N+1 문제를 해결해 볼 것이다. 위의 로직은 이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.