+ 1

JAVA: Error in Value & Reference Types?

There is some error there in the second question, it shows 3 errors and no result. What is the output of this code? public static void main(String[ ] args) { Person p = new Person(); p.setAge(25); change(p); System.out.println(p.getAge()); } static void change(Person p) { p.setAge(10); }

12th Nov 2019, 8:18 PM
Libor Benes
Libor Benes - avatar
2 ответов
0
swim: Thank you very much. Your code is working. (With just a portion of a code being presented for this Java exercise as the tasking, it is difficult to figure out the correct response. One would have to basically write a whole program around that part of the code - they way you have written - but that is difficult for beginners.)
13th Nov 2019, 9:09 AM
Libor Benes
Libor Benes - avatar