whats wrong with this class declaration?
public class hashTable3 {
int[]anArray = new int[100];
for (int i = 0; i < anArray.length; i++)
anArray[i] = -1;
}
Hi,
why is the class declaration above faulty?
The way I read it is that "int[]anArray = new int[100];" creates an integer array called anArray
then for the loop statement the array exists so why does the loop not work?
i get "an illegal start of type errror...."
for
for (int i = 0; i < anArray.length; i++)
anArray[i] = -1;
very dazed and confused
You call the method, not the class
What Serjant means is that your class needs a method (like he said... any method). When you make a call to a class, you have to call a method in the class... you don't call the class itself. You can two one of two things:
- wrap a main method around your code and be able to execute the class' code directly or
- wrap other method around it and call that method from another class.
Luck,
CJSL