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

  • Home
  • SEARCH
  • 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

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
all. We're trying to get some intersect collisions working, but the problem experience is
All, I have just reinstalled Java on my machine because I found I had
All, My classpath has been set to the following folder: CLASSPATH = .;C:\Program Files\Java\jdk1.6.0_21\bin;C:\Program
All the examples I can find using DLLImport to call C++ code from C#
All APIs in Hibernate are from 1.4 and are thus not using java generics.
All I'm trying to do is something fairly simple : Create a class (let's
All- I am trying to get the user's current location than display that on
I am trying to loop through a bunch of documents I have to put

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.