J2SE5.0 new feature automatic packing solution
晁 晁 攀 Smallnest@163.com
As a programmer, a Java programmer, often encounters the following situation when using Map and Collection:
Map Map;
...
String name = map.get ("name");
...
The value taken from the MAP object is required to force the conversion to what we need, and this situation is often encountered when reading attribute values in JSP.
Jesus, why don't you transfer to me into the type I need?
We now automatically implement boxes and solutions. Look at the example below:
Package com.kuaff.jdk5; import java.util.date; import java.util.hashmap; import java.util.map; public class boxing {private map
We declare a String, Date type MAP, using English should be (Map of string, Date) so we can directly pack Map.Put ("Date", new date (); reconciliation Date Date = MAP .get ("date");
This function can do not have a lot, at least we can do some letters, love our keyboard.