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:
Thank you very much Kishori!
Posted by DINH NGUYEN on July 27, 2000 at 9:26 PM
> Hi > You have typed one extra brace while defining Number class and that is why the definition of Assignment class is being treated as an innner class and you are getting error. Try the following and it works... > //Assignment with objects is a bit tricky > //package c03; > class Number { > int i; // you had extra brace in this line > } > 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); > } > } > Thanx > Kishori
Replies:
|