Passing an array variable from one method to the other

Thread Starter

krow

Joined May 25, 2010
49
I know how to do this when I'm just dealing simple integer values, very simple example using Java:

Rich (BB code):
public class NewClass{

    public static void main(String[] args) {

        first();
    }
static void first(){

    String a = "Hello world";
    second(a);

    }
 static void second(String b){

     System.out.println(b);

    }

}
But how do I do the same when I have string arrays?

Rich (BB code):
public class NewClass{

    public static void main(String[] args) {

        first();
    }
static void first(){

    String a[] = {"mary", "peter", "john"};
    
    //????

    }
 static void second(String b[]){

     //????

    }

}
I know I have to use FOR but I don't know how.

Thanks a lot in advance!
 
Top