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:

RE: You typed one extra brace

Posted by Kishori Sharan on July 27, 2000 at 9:13 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:

Sponsored Links



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