Help with NoClassDefFound error!

Like everyone here, I'm a Java newbie. I've only been learning it for 3 days (my previous language being GML, so I'm making quite a transition) from a book. The book told me to print the first 5 rows of Pascal's Triangle to the screen and detirmine the values mathematically.

When running my program:

/*

* PascalsTriangle.java

* PRINTS THE FIRST 5 LINES OF PASCALS TRIANGLE

* Derives values mathematically!

*/

import java.io.*;

import java.lang.*;

publicclass PascalsTriangle

{

publicstaticvoid main(String args[])

{

//declare Countd

boolean Countd =false;

//declare arrays

int[] Rowo ={ 1, 2};

int[] Rowt ={ Rowo[1], Rowo[1]};

int[] Rowth ={ Rowt[1], Rowt[1] + Rowt[2], Rowt[1]};

int[] Rowfo ={ Rowth[1], Rowth[1] + Rowth[2], Rowth[2] + Rowth[3], Rowth[3]};

int[] Rowfi ={ Rowfo[1], Rowfo[1] + Rowfo[2], Rowfo[2] + Rowfo[3], Rowfo[3] + Rowfo[4], Rowfo[4]};

//draw triangle while mathematically calculating

for (int Count = 0; Countd ==true ; Count++)

{

if (Count == 0)//Row 1

{

System.out.println(Rowo[1]);

}

if (Count == 1)//Row 2

{

System.out.println(Rowt[1] +"" + Rowt[2]);

}

if (Count == 2)//Row 3

{

System.out.println(Rowth[1] +"" + Rowth[2] +"" + Rowth[3]);

}

if (Count == 3)//Row 4

{

System.out.println(Rowfo[1] +"" + Rowfo[2] +"" + Rowfo[3] +"" + Rowfo[4]);

}

if (Count == 4)//Row 5

{

System.out.println(Rowfi[1] +"" + Rowfi[2] +"" + Rowfi[3] +"" + Rowfi[4] +"" + Rowfi[5]);

}

if (Count == 5)//End

{

Countd =true;

}

}

}

}

I get the error:

Exception in thread"main" java.lang.NoClassDefFoundError: PascalsTriangle/class

It has me stumpted. Could you tell me what's wrong with my code?

Also, once that problem is away, could you give me hints on making my code better and more efficient? I know I could have used the switch statement instead of multiplule ifs.

Thanks! ;)

[4292 byte] By [coolbho3000a] at [2007-10-2 20:34:34]
# 1

> > public static void main(String args[])

>

Try:

public static void main(String[] args) {

// ... the rest of your code

And the file name should be

PascalsTriangle.java

JJ

Java_Jaya at 2007-7-13 23:17:43 > top of Java-index,Java Essentials,New To Java...
# 2
When you run the program, the correct command isjava -cp . PascalsTriangleOmit the .class suffix
mvantuyla at 2007-7-13 23:17:43 > top of Java-index,Java Essentials,New To Java...
# 3
Nope, that didn't fix it. I know that it can be written both ways...
coolbho3000a at 2007-7-13 23:17:43 > top of Java-index,Java Essentials,New To Java...
# 4
> When you run the program, the correct command is> > java -cp . PascalsTriangle> > Omit the .class suffixOh, that fixed it!More exceptions...back to coding. Thanks guys!
coolbho3000a at 2007-7-13 23:17:43 > top of Java-index,Java Essentials,New To Java...