In my program I am getting a string from Database result set and convert it to char array like this:
emp.nid = rs.getString("nid").toCharArray();
In this part there is no error. The String is successfully converted to char array. But I have another code like this:
nid_txt.setText(emp.nid.toString());
This prints some freaky text. Not the original. Why was this happens? Please help me.
You're calling toString
on a char[]
- and that inherits the implementation from Object
, so you get the char[].class
name, @ and then the hash of the object. Instead, call the String(char[])
constructor:
nid_txt.setText(new String(emp.nid));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With