The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Getting error when trying to compile a very simple program!

Posted by DINH NGUYEN on July 27, 2000 at 8:29 PM

I keep getting the errors below when I am trying to compile the program from "Thinking in Java" by BruceEckel on pages 97 and 98.
I am using JDK1.2 and TextPad to compile java.
Would you please let me know what's going on?

Thank you so much for your help.

Sincerely,

Dinh Nguyen

//Assignment with objects is a bit tricky
//package c03;

class Number {
{ int i;
}

public class Assignment
{ public static void main(String[] args)
{
Number n1 = new Number();
Number n2 = new Number();
n1.i = 9;
n2.i = 47;
System.out.println("1: n1.i: " + n1.i + ", n2.i: " + n2.i);
System.out.println("2: n1.i: " + n1.i + ", n2.i: " + n2.i);
System.out.println("3: n1.i: " + n1.i + ", n2.i: " + n2.i);
}
}
-----------------------------------------------------------------
C:\jdk1.2\bin\Assignment.java:9: Method void main(String[]) can't be static in inner class Number. Assignment. Only members of interfaces and top-level classes can be static.
{ public static void main(String[] args)
^
C:\jdk1.2\bin\Assignment.java:19: '}' expected.
}
^
2 errors
Process completed successfully




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us