Package maoxiang.examples.jdk15;
Import java.util.abstractList;
Import java.util.list;
Import java.util.map;
Import java.util.treemap;
/ **
* @Author Mao Xiang
*
* Box converts the Primitive type into a compound object, such as converting Int into Integer
* Unbox converts a compound object to Primitive Integer.intValue ()
* /
Public class autoBoxing {
Public static void main (String [] args) {
Autoboxing test = new autoboxing ();
Test.test1 ();
}
Public void test1 () {
String [] args = new string [] {"1", "2", "3", "4", "5", "6", "7", "8"};
Map
For (String Word: args) {
Integer freq = m.get (Word);
M.PUT (Word, (freq == NULL? 1: FREQ 1);
}
System.out.println (M);
}
// list adapter for primitive int arch
Public Static List
Return New AbstractList
Public Integer Get (INT I) {
Return a [i];
}
// throws nullpointersRexception if Val == NULL
Public Integer Set (INT I, Integer Val) {
Integer OldVal = a [i];
a [i] = val;
Return OldVal;
}
Public int size () {
Return A.Length;
}
}
}
}