Question:
> Hi, I am having a baffling java problem. > Whenever I try to run a program, I get a message saying > Exception in thread "main" java.lang.NoClassDefFoundError: myNode > Even when I know there is nothing wrong with the program, > I get that message. Can you tell me how to fix that? Thanks.Answer: there two possible problems.
public static void main(Strings[] args) // OK, you COULD re-name // "args" if you like. But it is standard, why choose to confuse? public static void main() // error! public static int main() // error!
public static void main(String[] args)
or
public static void main(String args[])
Common mistakes:
Unacceptable variants (some java compiler, esp. older ones may not complain):
public static void main()
// no arguments
public static int main(String args[])
// returns an int ("C" style main)
Another mistake of "C" programmers is to think
that args[0]
stores the number of
arguments in args[]. Of course, this number
is args.length
.
while (flag);
{
...body of while loop
}
// the compiler does not complain but the
// effects of this code is surely wrong!
int i = 2; int j = 3; double k = i/j;
foo X = new foo();