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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:14:35+00:00 2026-06-11T13:14:35+00:00

I just started learning java and I’m working on a program. I’m getting an

  • 0

I just started learning java and I’m working on a program. I’m getting an error here:

locationsOfCells = simpleDotCom.getLocationCells();

but I’m not sure what the error is. Eclipse say

Cannot make a static reference to the non-static method
getLocationCells() from the type simpleDotCom

Can someone help me with this? What am I doing wrong?

public class simpleDotCom {
    int[] locationsCells;

    void setLocationCells(int[] loc){
        //Setting the array
        locationsCells = new int[3];
        locationsCells[0]= 3;
        locationsCells[1]= 4;
        locationsCells[2]= 5;
    }

    public int[] getLocationCells(){

        return locationsCells;

    }
}

public class simpleDotComGame {

    public static void main(String[] args) {
        printBoard();
    }

    private static void printBoard(){
        simpleDotCom theBoard = new simpleDotCom();
        int[] locationsOfCells; 
        locationsOfCells = new int[3];
        locationsOfCells = theBoard.getLocationCells();

        for(int i = 0; i<3; i++){
            System.out.println(locationsOfCells[i]);
        }

    }

}
  • 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-06-11T13:14:36+00:00Added an answer on June 11, 2026 at 1:14 pm

    The problem is you are calling the getLocationCells() method as if it was a static method when in fact it is an instance method.

    You need to first create an object from your class like this:

    simpleDotCom myObject = new simpleDotCom();
    

    and then call the method on it:

    locationsOfCells  = myObject.getLocationCells();
    

    Incidentally, there is a widely followed naming convention in the Java world, where class names always start with a capital letter – you should rename your class to SimpleDotCom to avoid confusion.

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

Sidebar

Related Questions

Ok so I've just started learning java (I usually program in Objective-C). My first
I'm familiar with C++ but never used Java. I've just started learning Android development.
i just started learning swings. And thought of trying out a simple program, but
This is probably a really stupid error but iv'e just started learning the .awt
I've just started learning Java and have come across a little quirk I'm not
I've just started learning Java (about a week ago) and the last few days
I've just started learning LWJGL (Java OpenGL), and i'm encountering an enormous amount of
I just started learning C++ (coming from Java ) and am having some serious
I am in an introductory java course and we just started learning about inheritance.
I have just started leaning and working on xquery with java. I have a

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.