-2

a simple android program which accept a user id and user name, and store them inside an arrayList using a subclass called Student. There are 2 buttons, one of them record the information and the other one display them. The top button seem to work fine, but for the other one it display something that looks like the address instead of the actual data, what's the problem? Thanksmain code class code unexpected output

Sunny
  • 3,134
  • 1
  • 17
  • 31
omoisama
  • 43
  • 5

2 Answers2

1

Override Object.toString() in your Student class.

//Sample code
public String toString() {
        return "id of the student:" + this.id + ",, "
                + "name of the student:" + this.name ;
    }

For more info, see this answer

Jitendra A
  • 1,568
  • 10
  • 18
  • U r welcome @omoisama, If the answer is satisfactory then pls accept it so that others with the same issues can benefit from it – Jitendra A Sep 18 '18 at 14:21
0

use this code for you funclist method

    private void funclist(){
        StringBuilder output = new StringBuilder();
        for(int i=0;i<studentList.seize();i++){
        output.append(studentList.get(i) + "\n");
        }
    }

this will convert your object to string or you can add

    studentList.get(i).toString()

instead of your code.