| 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 .
|
 |
 |
|
|
subject: Doubt with String Methods
|
|
|