The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 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:

Compiler choking on Anonymous Inner Class

Posted by pfrontie on October 06, 2000 at 5:58 PM

I'm a beginning Java programmer and am going through Bruce Eckel's "Thinking in Java" book. Here is the fairly simple code I am trying to run. The compiler is giving me the following error, "Class InnerProblem18 not found in type declaration or import." This error doesn't seem to make sense. In general, my compiler doesn't seem to "like" inner classes, as I have tried to compile some of the example source code dealing with Anonymous Inner Classes, and that chokes also. Any ideas?

package Eckel.Chapter8.package1;

/**
*
* @author PFRONTIE
* @version
*/

public class Problem18 extends Object {
private double d = 10.00;
private double multiplyDD(){
return d*5.00;
}
/** Creates new Problem18 */
public Problem18() {
}

public InnerProblem18 innerExtend() {
return new InnerProblem18() {
private int k = 5;
};
}

public void callInner(){
/*InnerProblem18 ip18 = innerExtend();
ip18.incrementD();*/
}

public static void main(String[] args){
Problem18 p18 = new Problem18();
System.out.println(p18.d);
InnerProblem18 ip18 = p18.callInner();
System.out.println(p18.d);
}
}



Replies:
  • replay Jose Botella October 08, 2000 at 7:57 AM (0)

Sponsored Links



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