toString details

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

  • : 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.

Howdy, Stranger!

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

Categories

In this Discussion