Why am I getting the warning :Class is a raw type. References to generic type Class<T> should be parameterized"?

android, java

Solution

Class is generic, if you don't care for the warning you have two choices use `@SuppressWarnings("rawtypes")` or my preference use the `<?>` (that is a wildcard capture) like this

Class<?> ourclass = Class.forName("com.app1."+cheese);

Problem

I am getting warning in my `ListActivity`. The warning I am getting is shown below - `Class is a raw type. References to generic type Class<T> should be parameterized` It is not creating any problems, but I would like to know why I am getting this warning and how to suppress it. See line which written within asterisks. ``` public class Menu extends ListActivity { String classes[]={"Second","example1","example2","example3","example4"}; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter<String>(Menu.this,android.R.layout.simple_list_item_1,classes)); } @Override protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); String cheese=classes[position]; try{ **Class ourclass= Class.forName("com.app1."+cheese);** Intent ourintent= new Intent(Menu.this,ourclass); startActivity(ourintent); }catch(ClassNotFoundException e){ e.printStackTrace(); } } } ```

Original source