zoukankan      html  css  js  c++  java
  • JAVA打印变量类型

    //输出变量类型的类,
    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("玛丽","仓吉");

    }
    }
  • 相关阅读:
    Android Architecture Components
    adb命令
    Dagger2 scope
    Dagger2学习资源
    Dependency Injection学习笔记
    什么是ADB
    使用AndroidStudio dump heap,再用 Eclipse MAT插件分析内存泄露
    Dagger学习笔记
    linux & shell & nginx & Docker Kubernetes
    Go 目录
  • 原文地址:https://www.cnblogs.com/wsnan/p/11650507.html
Copyright © 2011-2022 走看看