This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Guys...I was reading the Wapper Conversion rules and was trying to do the following, which is now giving me NumberFormatException. May be the basic part for Wrapper Class I am missing here to understand correctly. Can any one please help me to be on the right side?
But why that is not Widening the value for me? Isn't it an automatic process in Java? Or what i was trying to do is illegal in Java ! I know that Wrapper's second big function is convering stuff....so why can't i do that here?
Can you please show me a good example on converting a String to a Wrapper?
Strings aren't wrapped. If you look at the JavaDoc for Integer.valueOf(String s), you'll see that it's quite clear that if the String doesn't represent an integer value, you'll see the NumberFormatException you got. If you want to convert a String representing a floating point number, you'll have to add an intermediate step.