Sometimes we may need in java programming to pass the value of array in another function.
Here I have given an example about the procedure of passing an array to a function.
Also, here I have shown how to find out the length of an array and how to retrieve or get the value of the array after passing it to another function.
This tutorial will help you to understand the basic of array and how to declare array in java.
Code:
class ArrayPassing
{
public static void checking(String[] u)
{
System.out.println(“\n”);
System.out.println(“****************************************”);
System.out.println(“Array is entered into Checking function”);
System.out.println(“Array Length:”+u.length);
System.out.println(“Third index value is:”+u[2]);
System.out.println(“\n”);
System.out.println(“****************************************”);
}
public static void main(String args[])
{
String[] d;
d = new String[3];
d[0]=”1″;
d[1]=”2″;
d[2]=”5″;
checking(d);
}
}
OUTPUT: