0

Java beginner here. I have an array of objects and need to be able to change one part of a particular object. For example: "A", 95 change it to "A", 96

Grade [] grades = {
    new Grade ("A", 95}, 
    new Grade ("B", 90)
};

I have the Grade class with Grade constructor, gets and sets

Grade(letter, number);

I keep trying to code something in the main method and it tells me that I cat access get or set on an Array.

2
  • 1
    You can edit the question, better than correcting yourself in comments. Commented Feb 22, 2016 at 0:49
  • 2
    Please edit your question rather than posting corrections in comments... Commented Feb 22, 2016 at 0:49

1 Answer 1

1
Grade [] grades = {
    new Grade ("A", 95}, 
    new Grade ("B", 90)
};

creates the array then to access elements it would be:

grades[0].getLetter(); // which would return "A"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.