Is it possible to pass an array in a class to a method of the same class. Or is this bad programming?
The compiler complains about this example bit of code:
test.java(7): Can't make static reference to method void displayArray(int[]) in
test public class test
{
public static void main(
String[] args)
{
int array[] = {0,1,2,3,4,5,6,7,8,9};
displayArray(array);
}
void displayArray(int values[])
{
for (int i = 0; i < values.length; i++)
{
System.out.println(values[i]);
}
}
}