• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where is Wrapper class toString method? (To ARS Kumar)

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, ARS Kumar;
Your answers to both my questions help me a lot.
but I still can not figure out why in System.out.println() method, Wrapper class toString() method is not invoked as do most of Objects.
Can you further help me with this?
TIA
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason
I am glad that my answers helped you. But again this question
Please try this code
public class WrapperTest {
public static void main(String args[]) {
Integer ten1 = new Integer(10);
int ten2 = 10;
System.out.println("Wrapper :- " + ten1);
System.out.println("Primitive :- " + ten2);
}
}
What we discussed in your other posting was about using + operator for adding a Integer wrapper class object and a int primitive variable which will create a problem. If you just want to use a Wrapper class object in System.out.println(), it will work as the code demonstrates.
Thanks
ARS Kumar.
[This message has been edited by ARS Kumar (edited June 17, 2000).]
reply
    Bookmark Topic Watch Topic
  • New Topic