Java tutorial
//package com.java2s; public class Main { public static <T> T getArgument(int index, Class<T> clazz, Object... objects) { T ret = null; if (objects != null && index < objects.length && clazz != null && clazz.isInstance(objects[index])) { ret = clazz.cast(objects[index]); } return ret; } }