1. package s02.e05;
    2. import lombok.Getter;
    3. import lombok.NoArgsConstructor;
    4. import lombok.Setter;
    5. @NoArgsConstructor
    6. @Getter
    7. @Setter
    8. public class Person {
    9. private Integer id;
    10. private String personName;
    11. public Person(String personName) {
    12. this.personName = personName;
    13. }
    14. }
    1. package s02.e05;
    2. public class TestTransferValue {
    3. public void changeValue1(int age) {
    4. age = 30;
    5. }
    6. public void changeValue2(Person person) {
    7. person.setPersonName("xxx");
    8. }
    9. public void changeValue3(String str) {
    10. str = "xxx";
    11. }
    12. public static void main(String[] args) {
    13. TestTransferValue test = new TestTransferValue();
    14. int age = 20;
    15. test.changeValue1(age);
    16. System.out.println("age----" + age);
    17. Person person = new Person("abc");
    18. test.changeValue2(person);
    19. System.out.println("personName-----" + person.getPersonName());
    20. String str = "abc";
    21. test.changeValue3(str);
    22. System.out.println("String-----" + str);
    23. }
    24. }

    image.png
    image.pngimage.png