import java.util.ArrayList;
/*
* Generics: new features of java jdk1.5.
* Benefits of generics:
* 1. Advance runtime errors to compile time.
* 2. Avoid unnecessary forced type conversion.
*
* Custom method generic: A custom generic is a placeholder for a data type or a data type variable. Generally, T type or E element is used as the placeholder symbol
* The placeholder symbol can be written at will. Naming conventions for identifiers must be followed.
* Format of method generics:
*
*
* If you pass in a basic data type: its wrapper class has been used when receiving it. .
* int ----> Integer;
* short ---> Short
* double ---> Double
* float ----> Float
* byte ----> Byte
* boolean --->Boolean
* long ---> Long
* char ---> Character
*
*
*/
public class Demo2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//Requirement: Change the elements in a collection from lower case to upper case
/*ArrayList
list.add("aa");
list.add("bb");
list.add("cc");
list.add("dd");
//list.add(123); //Error reported when running
for(int i = 0;i
System.out.println(list.get(i).toUpperCase());
}*/
String s = test("abc");
Integer i = test(123);
}
public static
return s;
}
}