java - Return two string in toString function -


@entity public class person {  private integer id = null; private string name = null; private string price = null; private date created = null;  // string representation: @override public string tostring() {     return name;    // want return name , price  } 

i want return name , price in tostring function ? right return more 1 string in tostring function. if make relation in other's entity manytomany ?

please suggest me if doing right or wrong want show these fields in other entity make relations.

thanks!

usually tostring() method returns string-representation of object , not object's members themself. if need representation of name , price do

return "name: " + name + ", price: " + price; 

if want receive members name , price should generate getters , use them in caller.

another possibility "wrap" 2 strings in sort of data class.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -