欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java 基本类型,

来源: javaer 分享于  点击 37422 次 点评:99

java 基本类型,


基本类型

float/double -> Float/Double -> 4/8 bytes

byte/short/int/long - > Byte/Short/Integer/Long -> 1/2/4/8 bytes

char -> Character -> 2 bytes

boolean -> Boolean -> ?

直接常量

byte、short、int、char、long都可用八进制和十六进制数常量表示;

long/float/double 常量表示: L(l)/F(f)/D(d);

类型自动提升

byte ->short(char)->int->long->float->double

Java表达式转型规则由低到高转换(1)所有的byte,short,char型的值将被提升为int型;

(2)如果有一个操作数是long型,计算结果是long型;

(3)如果有一个操作数是float型,计算结果是float型;

(4)如果有一个操作数是double型,计算结果是double型;(5)被final修饰的变量不会自动改变类型,当2个final修饰相操作时,结果会根据左边变量的类型而转化。

switch支持的数据类型

byte/short/char/int String Enum

基本数据类型与String间的转换

基本类型 - > String 

    基本类型+"" 、基本类型.toString()

String -> 基本类型 

    Xxx.parseXxx(string); //返回基本类型

    Xxx.vauleOf(string);//返回基本类型的包装类

相关文章

    暂无相关文章
相关栏目:

用户点评