• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Doubt with String Methods

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not able to understand the clear difference between xxxValue(),ParseXxx() and valueOf() methods. Any one can explain me these with simple example?
Thanks
 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have K & B for (java-5) book? If you have read page-230 & 231 care fully. You will clear.
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To use the first one xxxValue() method you need to have an object created already. For example:

Integer i = new Integer(15);
System.out.println(i.intValue());
System.out.println(i.byteValue());
System.out.println(i.doubleValue());

it will print out the int, byte, double primitive values of the Integer object i.


The following two: parseXxx() and valueOf() are static methods. So that means you can call them by using Integer.parseXxx() or Integer.valueOf().

And the difference betweent the two is that parseXxx() returns primitive but valueOf()returns object. They generally takes String as input. For example:

int a = Integer.parseInt("15");
System.out.println(a);

Integer b = Integer.valueOf("15");
System.out.println(b);
 
anmita payal
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tony Smith for explaining .
 
Attractive, successful people love this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic