aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt with String Methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Doubt with String Methods" Watch "Doubt with String Methods" New topic
Author

Doubt with String Methods

anmita payal
Greenhorn

Joined: Jun 22, 2007
Posts: 23
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
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Do you have K & B for (java-5) book? If you have read page-230 & 231 care fully. You will clear.


SCJP-1.5<br />SCWCD-1.4
Tony Smith
Ranch Hand

Joined: Jul 07, 2007
Posts: 229
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

Joined: Jun 22, 2007
Posts: 23
Thanks Tony Smith for explaining .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt with String Methods