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 6816675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:57:14+00:00 2026-05-26T20:57:14+00:00

For an assignment I need to create a class within class Point from java.awt.Point.

  • 0

For an assignment I need to create a class within class Point from java.awt.Point. I need to be able to use point methods while creating my own variables for the inner/nested class. I am a bit confused by the differences between static nested classes and inner classes and dont know which one to use. I have tried to use a static nested class and have encountered an error stating “modifier static not allowed here”

My misguided attempt:

class Point {
    static class RobotJAW {

        int goldcollected, x, y;

        RobotJAW() {
            goldcollected = 0;
            alive = true;
            x = 0;
            y = 0;
        }

    }
}

The point of creating this class it to have a robot search a field of gold and bombs and collect gold while being destroyed by bombs. I can only use the Point and Scanner classes from the java API. I need to use the point methods equals(obj), move(int x, int y), getLocation(), and setLocation(int x, int y). But I need to add goldcollected and alive variables. Also, this is an assignment for school, so I would like to gain some more knowledge about the subject, and some guidance, without being given someone elses work.

  • 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-26T20:57:15+00:00Added an answer on May 26, 2026 at 8:57 pm

    A lesson about how inner classes work, then some doubts that that is what you really need.
    An inner class is used for describing a class with an extremely strong belongs-to relationship to another class. So strong infact, that it cannot survive without the outer class. So strong, that you rarely need it. The inner class is only accessible through an instance of the outer class:

    public class A{
      public int value1;
      public class B{
        public int value2;
      }
    }
    ...
    A a1 = new A()
    a1.value1 = 202
    A.B b1 = new a1.B();
    System.out.println(b1.value1); //Prints 202
    A.B b2 = new B(); //Compiler error! Not allowed
    

    A static inner class is not really an inner class. It is just a class that is defined inside of an inner class.

    It looks to me like what you want is for RobotJaw to either be a point, or have a point. You don’t want it to be an object unattachably contained by a point. So either have RobotJaw extend a Point, or contain a point.

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

Sidebar

Related Questions

I have a homework assignment where I need to take input from a file
I need to make a 2D convex hull function for a class assignment and
I'm new to Java and for a HW assignment, we had to create a
I'm working on an assignment for a class, and need a bit of direction.
I have a school assignment where I need to create a data-driven style of
I have a Assignment question about Java Generics. The given class is Product.java. It
I need to create an generic data access layer to use in my final
For a homework assignment i need to create a List<T> , add objects to
I have an assignment that I need to create a custom C type string
I am working on creating a threadpool from scratch as part of an assignment

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.