Java Object Oriented Design: Returning multiple objects in java
问题 The below code in Java throws Null pointer exception. public class New{ int i; New(int i) { this.i = i; } public void func(New temp) { temp.i = 10; temp = new New(20); } public static void main(String[] args) { New n = null; n.func(n); System.out.println("value "+ n.i); } } The reason being, java passes objects references by value. If I wanted to return one object, then I can return it from the function. But, If I have multiple objects, the only way I could return the object references is, by