java - How to print the content of an object -
when start program, gives me link object, while want content. where's mistake?
i think problem lies in storage.addrecord(record) in readerxls.class.
result:
reading on start reading storage work2obj.record@2910d926 .
public class start { public static void main(string[] args) { system.out.println("start reading xls"); readerxls read = new readerxls(); storage storage; storage = read.readxls("text1obj",0,1); system.out.println("reading over"); system.out.println("start reading storage"); system.out.println(storage.getrecord(1)); } } .
public class storage { list<record> record; public storage(){ this.record = new arraylist<record>(); } .
public record getrecord(int number){ return this.record.get(number); } } .
public class readerxls { public storage readxls(string sfilename,int firstcolumn, int lastcolumn){ storage storage = new storage(); try { record record = new record(j, integer.parseint(contentcount), rowcontent); storage.addrecord(record); } }
you should implement tostring method in record class return string containing data want display.
by default, since class doesn't implement tostring, object.tostring() gets called, returns <the name of class>@<the object's hashcode>
Comments
Post a Comment