一、概述:

此方法主要用来判断Class是否为原始类型(boolean、char、byte、short、int、long、float、double)。

二、格式:

Class.isPrimitive(),原始类型下返回true

三、示例:

public static void main(String[] args){

    Class stringClass=String.class;
System.out.println("String is primitive type:"+stringClass.isPrimitive()); Class booleanClass=Boolean.class;
System.out.println("Boolean is primitive type:"+booleanClass.isPrimitive()); Class booleanType=boolean.class;
System.out.println("boolean is primitive type:"+booleanType.isPrimitive()); Class byteType=byte.class;
System.out.println("byte is primitive type:"+byteType.isPrimitive()); Class charType=char.class;
System.out.println("char is primitive type:"+charType.isPrimitive()); Class shortType=short.class;
System.out.println("short is primitive type:"+shortType.isPrimitive()); Class intType=int.class;
System.out.println("int is primitive type:"+intType.isPrimitive()); Class longType=long.class;
System.out.println("long is primitive type:"+longType.isPrimitive()); Class floatType=float.class;
System.out.println("float is primitive type:"+floatType.isPrimitive()); Class doubleType=double.class;
System.out.println("double is primitive type:"+doubleType.isPrimitive());
}

结果输出:

String is primitive type:false
Boolean is primitive type:false
boolean is primitive type:true
byte is primitive type:true
char is primitive type:true
short is primitive type:true
int is primitive type:true
long is primitive type:true
float is primitive type:true
double is primitive type:true

java.lang.Class.isPrimitive()用法解析的更多相关文章

  1. java.lang.Class.isAssignableFrom()用法解析

    一.概述: 此方法主要用来判断 "参数类" 是否是 "源类" 的子类.接口实现类,或者与 "源类" 相同,在此情况下返回 true; 二.格 ...

  2. java.lang.String.indexOf()用法

    java.lang.String.indexOf(char ch) 方法返回字符ch在指定字符串中第一次出现的下标索引位置 如果字符ch在指定的字符串中找不到,则返回-1 示例: import jav ...

  3. java.lang.IllegalThreadStateException异常原因解析

    前几天写了个小程序,运行的时候发现在循环第二遍的时候出现了java.lang.IllegalThreadStateException异常 通过上网查询发现同一个Thread不能重复调用start方法, ...

  4. 【JDK】:java.lang.Integer源码解析

    本文对JDK8中的java.lang.Integer包装类的部分数值缓存技术.valueOf().stringSize().toString().getChars().parseInt()等进行简要分 ...

  5. Java super与this用法解析

    1.     子类的构造函数如果要引用super的话,必须把super放在函数的首位. class Base { Base() { System.out.println("Base" ...

  6. Java中static的用法解析

    知识点1.static关键字a.可以修饰变量,方法,代码块b.修饰的变量和方法可以使用类名.变量名/类名.方法名调用c.static修饰的资源为静态资源,在类加载的时候执行d.在静态方法中只能调用静态 ...

  7. json解析异常 - net.sf.json.JSONException: java.lang.reflect.InvocationTargetException

    注:在项目中, 我使用原生的ajax请求数据的时候, JSONObject没能帮我解析, 当却不给我报错, 我是在junit单元测试中测试的时候, 发现的.发现好多时候, 特别是通过ajax请求, 不 ...

  8. 【Java学习笔记之二十二】解析接口在Java继承中的用法及实例分析

    一.定义 Java接口(Interface),是一系列方法的声明,是一些方法特征的集合,一个接口只有方法的特征没有方法的实现,因此这些方法可以在不同的地方被不同的类实现,而这些实现可以具有不同的行为( ...

  9. 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]

    spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...

随机推荐

  1. 使用蓝灯后,IE浏览器以及内置IE浏览器的程序不能使用的解决方案

    使用完蓝灯后,每次使用IE浏览器都不能正常使用,于是有了下面的这个方案 1.通过Win+R 打开注册表编辑器(regedit) 进入目录 HKEY_CURRENT_USER \ Software \ ...

  2. css常用hack

    原文地址:css常用hack 突然想起今天早上在CNZZ看到的统计数据,使用IE6.7的用户比例还真多,看到之后我的心都碎了.微软都放弃了为毛还有这么多人不死心? 所以说,IE下的兼容还是得做的. – ...

  3. .Net语言 APP开发平台——Smobiler学习日志:手机应用的TextTabBar快速实现方式

    参考页面: http://www.yuanjiaocheng.net/webapi/create-crud-api-1-put.html http://www.yuanjiaocheng.net/we ...

  4. jquery.multiselect 多选下拉框实现

    第一步:链接下列文件,如果没有,到此网页下载 https://github.com/ehynds/jquery-ui-multiselect-widget,此插件基于jquery ,所以jquery的 ...

  5. 参数探测(Parameter Sniffing)影响存储过程执行效率解决方案

    如果SQL query中有参数,SQL Server 会创建一个参数嗅探进程以提高执行性能.该计划通常是最好的并被保存以重复利用.只是偶尔,不会选择最优的执行计划而影响执行效率. SQL Server ...

  6. linux下安装Redis以及phpredis模块

    一:redis的安装 1. 首先上官网下载Redis 压缩包,地址:http://redis.io/download 下载 2. 通过远程管理工具,将压缩包拷贝到Linux服务器中,执行解压操作 3. ...

  7. 论C#逼格手册

    水文.如何让自己的代码看起来,更有逼格? 要想让自己的代码,看起来更优雅,更有逼格,更高大上,就一定要写出晦涩难懂,而又简洁的代码来. 对于类自身的全局变量,一定要加this,对于基类的,一定要加ba ...

  8. MongoDB Java Driver操作指南

    MongoDB为Java提供了非常丰富的API操作,相比关系型数据库,这种NoSQL本身的数据也有点面向对象的意思,所以对于Java来说,Mongo的数据结构更加友好. MongoDB在今年做了一次重 ...

  9. ABP教程-给项目添加SwaggerUI,生成动态webapi

    上一篇,我们是正式将ABP生成的代码项目,跑起来了,然后演示了下多租户的不同.那么这篇我们就来实现下SwaggerUI. Q:SwaggerUI是干什么的呢? A:他是一个能将我们的webapi,通过 ...

  10. ceph架构剖析

    unitedstack有云 :https://www.ustack.com/blog/ceph_infra/