How to pass an Array to AngularJS?

How to pass an "Array of Class" as a parameter into a Method (in JAVA)?

  • There are my codes... public static void main(String[] args) { IceCream[] flavour = new IceCream[2]; flavour[0] = new IceCream("Mint", false); flavour[1] = new IceCream("Chocolate", false); fnMainMenu(flavour); //what is the correct way to pass in the array of class? } private static void fnMainMenu(IceCream[] flavour) //what should be in the brackets? { } class IceCream { some declaration of variables here } In C++ we can create an array of Struct to hold values and pass the array of Structs to other functions. But Java only have classes. I intend to pass an array of class to a Method, but I am not sure of the syntax. Anyone could enlighten me? Thank you!!

  • Answer:

    void fnMainMenu( IceCream[] f ) { // do whatever } IceCream findFlavor( IceCream [] f ) { for( int i = 0; i<f.length() ) { if( f[i].getFlavor().equalsIgnoreCase("Rocky… ) return f[ i ]; return null; } // be cautious, Java passes Objects by reference. Java may be your learning tool for what an Object really is, c++ fails to make the whole point of Objects emphatic. You may think of Objects in c++ as 'final', but not in Java unless you declare 'final'.

Executor at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.