Hi,
I just started to do some
java and I just bought "Head First Java.
While I was
testing the pool Puzzle exercise of the chapter 4 I had a error from (I think) the JVM.
I can compile (I still think) because when I do, javac Puzzle4.java, I get a Puzzle4.class in my folder. So I think the compilation was successful.
When I want to execute the program: java Puzzle4, I get the following message:
Exception in
thread "main" java.lang.NoClass.DefFoundError: Puzzle4
What does this mean?
Here is my code:
public class Puzzle4
{
public static void main (
String[] args)
{
Puzzle4b[] obs = new Puzzle4b[6];
int y = 1;
int x = 0;
int result = 0;
while ( x < 6)
{
obs[x] = new Puzzle4b();
obs[x].ivar = y;
y = y * 10;
x = x + 1;
}
x = 6;
while ( x > 0 )
{
x = x - 1;
result = result + obs[x].doStuff(x);
}
System.out.println("result " + result);
}
}
class Puzzle4b
{
int ivar;
public int doStuff( int factor )
{
if ( ivar > 100 )
{
return ivar * factor;
}
else
{
return ivar + ( 5 - factor );
}
}
}
Can somebody tell me what is going on in the java engine?
Thanks,
Jean-Marc