Results 1 to 3 of 3
  1. #1
    cknew1 is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default Indirect object access in JAVA

    Indirect object access in JAVA

    I am trying to understand how to indirectly access objects.

    Using the following simple Customer Class. For example, here are two of 50 Customer objects. They are Bill and Bob.

    public class Customer {
    private int CustNum;
    private String name;
    private String homePhone;

    Customer Bill = new Customer(100, "Bill West","1234567890");
    Customer Bob = new Customer(101, "Bob East","1234567891");

    I then wish to perform tasks on a certain object.
    i.e. I want to work on object "Bob"

    String custObj= "Bob";

    int dummynum = &custObj.CustNum;

    I would like dummynum to contain the value 101.

    You could even extend this to

    String custObj= "Bob";
    String custField= "CustNum";

    int dummynum = &custObj.&custField;

    The thought is to create dynamic flexible methods.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Indirect object access in JAVA

    What does "indirectly access" mean? You need a reference to an object to be able to access it.

    If you want to get a reference to an object using a String, put the objects in a Map with the String as the key and the object as the value.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Indirect object access in JAVA

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Can't access Object of JavaScript
    By scsvel in forum New To Java
    Replies: 2
    Last Post: 06-28-2011, 07:11 AM
  2. Access object variables
    By AcousticBruce in forum New To Java
    Replies: 6
    Last Post: 01-10-2011, 09:41 AM
  3. Object access between classes
    By qazplm123890 in forum AWT / Swing
    Replies: 1
    Last Post: 03-05-2009, 05:00 AM
  4. how to access to an object from a thread
    By tamayo in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 04:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts