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

The Archive Base Latest Questions

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

I have recently started learning java as my first ever step into object oriented

  • 0

I have recently started learning java as my first ever step into object oriented programming and have been having trouble with having my objects interact properly, so I have a few questions, which seem to be incredibly simple but for some reason I cannot find the answers elsewhere:

Firstly, I have been trying to have one object read values from another, in this case it is an object called “game” reading attributes from multiple objects called “Item”, the only way I can have the game object read any value from the item object is by having a method in the item class which returns the value which I want, and considering that each item has many attributes that I would like the game class to be able to read this simply does not seem like a particularly effective way to do this. So, is there any way to simply read values from an object? for example simply refering to the variable as item1.points, or item2.name, where item 2 is the object name and points is the variable name within the object?

Secondly, When I am assigning values to each item (I have the user assign certain values at the beginning of the game) is there any way to simply loop the same questions asking for values of attributes and have them assigned to my items sequentially? ie item1 then item2 then item3 rather than having selection statements to decide which item I an up to?

basically that is all I am having trouble with at the moment, any help would be greatly appreciated. Also, before anyone asks me to simply look it up, I HAVE been trying to look it up to no avail, however I may simply be using the wrong keywords to search this so any help in that regard would be much appreciated as well.

Thanks

  • 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-21T11:12:01+00:00Added an answer on May 21, 2026 at 11:12 am

    I agree with Kyle about your first question. The java bean standard is based on accessor methods: getters and setters. IDEs like Eclipse help a lot auto generating these methods for you.

    About interacting over an object properties you can use the Apacha Commons Beanutils project to do that:

    // Copy properties from someObject to myTargetObject
    Map attributes = BeanUtils.describe(someObject);
    SomeBean myTargetObject = new SomeBean();
    
    for(String propertyName : attributes.keySet()){
      System.out.println("Value for attribute " + propertyName + " is " + attributes.get(propertyName));
    
      // Updates target object
      BeanUtils.setProperty(myTargetObject, propertyName, attributes.get(propertyName));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I started learning Java I too started with the ubiqutous Hello world app.
I recently started learning Python and I was rather surprised to find a 1000
I recently started reading Paul Grahams 'On Lisp', and learning learning clojure along with
I'm a junior developer and recently started working for a very small office where
I recently started a project where I was set to build an ADP based
I have developed for a number of years in Java, primarily for Linux and
Recently I just got assigned a project to develop a web application/site that uses
Currently, I program in Java and use Maven quite a bit. As so I've
I've recently purchased a Mac and use it primarily for C# development under VMWare
I was hoping someone could answer my quick question as I am going nuts!

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.