Skip to content
Advertisement

Java Returning method which returns arraylist?

I have one class with a method like this:

JavaScript

how can i call this method inside another class?

Advertisement

Answer

1. If that class from which you want to call this method, is in the same package, then create an instance of this class and call the method.

2. Use Composition

3. It would be better to have a Generic ArrayList like ArrayList<Integer> etc…

eg:

JavaScript
Advertisement