Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

toString details

WigzWigz Posts: 5Member
I have created a sort of members data base where by the members add themselves along with some details. The data is saved in an array and the details saved correspond to a details class. To show all the details for the members a toString is called. My problem is i cant get the program to display the details for one member. I can get it to either display the toString which is all the details or display the number of that member in the array.

Does anyone know how i can go about displaying a single members details.

Any help is much appreciated

Thanks

Comments

  • zibadianzibadian Posts: 6,349Member
    : I have created a sort of members data base where by the members add themselves along with some details. The data is saved in an array and the details saved correspond to a details class. To show all the details for the members a toString is called. My problem is i cant get the program to display the details for one member. I can get it to either display the toString which is all the details or display the number of that member in the array.
    :
    : Does anyone know how i can go about displaying a single members details.
    :
    : Any help is much appreciated
    :
    : Thanks
    :
    Depending on the precise implementation I would guess something like this:
    [code]
    System.out.println(dataList[6].toString());
    [/code]
    This should show the toString() of the 7th record in the array.
    If you want to show a single field in a record, then you need to have a method, which returns that field:
    [code]
    class Data {
    private int someIntField;

    public int getSomeIntField() {
    return this.someIntField;
    }
    }
    [/code]
    [code]
    System.out.println(dataList[6].getSomeIntField());
    [/code]
    This will show the value stored in someIntField.
Sign In or Register to comment.