Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 705139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:01:12+00:00 2026-05-14T04:01:12+00:00

All, I’m going through the Friedman & Felleisen book A Little Java, A Few

  • 0

All,

I’m going through the Friedman & Felleisen book “A Little Java, A Few Patterns”. I’m trying to type the examples in DrJava, but I’m getting some errors. I’m a beginner, so I might be making rookie mistakes.

Here is what I have set-up:

public class ALittleJava {
  //ABSTRACT CLASS POINT
  abstract class Point {
    abstract int distanceToO();
  }
  class CartesianPt extends Point {
    int x;
    int y;
    int distanceToO(){
      return((int)Math.sqrt(x*x+y*y));
    }
    CartesianPt(int _x, int _y) {
    x=_x;
    y=_y;
    }
  }
  class ManhattanPt extends Point {
    int x;
    int y;
    int distanceToO(){
      return(x+y);
    }
    ManhattanPt(int _x, int _y){
      x=_x;
      y=_y;
    }
  }
}

And on the main’s side:

public class Main{
  public static void main (String [] args){
    Point y = new ManhattanPt(2,8);
    System.out.println(y.distanceToO());
  }
}

The compiler cannot find the symbols Point and ManhattanPt in the program.

If I precede each by ALittleJava., I get another error in the main, i.e.,

an enclosing instance that contains ALittleJava.ManhattanPt is required

I’ve tried to find ressources on the ‘net, but the book must have a pretty confidential following and I couldn’t find much.

Thank you all.

JDelage

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:01:12+00:00Added an answer on May 14, 2026 at 4:01 am

    Make your inner classes static, otherwise you’ll need to access your inner classes from an instance of ALittleJava, such as ALittleJava java = new ALittleJava(), which doesn’t seem to match your use case.

    static inner classes cannot see the members of their enclosing class, and if classes are nonstatic, conversely, they CAN see the members of their enclosing class, and an enclosing instance is in fact required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I started learning Java threads in the past few days and have only
All the examples of Silverlight using MVVM use interface named IPropertyChanged. What is the
all, I started out with what i thought was going to be a pretty
All I get is an error box saying: Unexpected file format. Everything was going
I am trying to loop through a bunch of documents I have to put
All the articles I've found via google are either obsolete or contradict one another.
All the recent VisualSVN Server posts made me want to check it out. I
All front-end developers know the pain of coding for Firefox, then viewing our then
All I know about the constraint is it's name ( SYS_C003415 ), but I
All I want is to be able to change the color of a bullet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.