//输出变量类型的类,
public class getType {
public static String getType(Object test) {
return test.getClass().getName().toString();
}
public static void main(String[] args) {
int i = 1;
System.out.println(getType(i));
}
}
public class StudentTestMethod {
//定义输出考试学生的人数及姓名的方法
public void print(String...names){ //names为调用方法的传入参数,参数个数不固定,随意可变,最后传入的参数以数组的形式保存在names中
int count=names.length;
System.out.println("names的类型是:"+names.getClass().getTypeName());//输出names变量的数据类型
System.out.println("本次参加考试的有"+count+"人,名单如下:");
for(int i=0;i<names.length;i++){
System.out.println(names[i]);
}
}
public static void main(String [] args){
//TODO Auto-generated method stub
StudentTestMethod student=new StudentTestMethod();
student.print("张三","李四","王五");
student.print("玛丽","仓吉");
}
}