| Author |
difference between the two
|
Mahesh Bamane
Ranch Hand
Joined: Mar 12, 2008
Posts: 66
|
|
I would like to know the difference between new String(byte[],encoding) and new String().getBytes(encoding).
Please explain.
|
There is nothing like trying, either you do it or you don't.
SCJP 1.5
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16480
|
|
The first one produces a String as the result. The second one produces a byte array as the result.
There are more differences, but you only asked for one.
|
 |
Mahesh Bamane
Ranch Hand
Joined: Mar 12, 2008
Posts: 66
|
|
|
Please, you can go ahead and tell them all ;)
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
Java™ Platform, Standard Edition 6 - API Specification.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
The first takes a byte[] and creates a String with its contents. The second creates a new empty String, then retrieves its bytes in a specific encoding, then throws away this empty String. The byte[] should be empty.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: difference between the two
|
|
|