byte、char、short运算
来源:互联网 发布:淘宝怎样上传数据包 编辑:程序博客网 时间:2024/06/07 05:19
/** * 表达式类型提升规则:所有的byte,short,char型的值将被提升为int型, * 一个操作数是long,结果是long型,一个操作数是float,结果是float型, * 一个操作数是double,结果是double型, * fianl修饰的变量不会自动改变类型, 当2个final修饰相操作时,结果会根据左边变量的类型..... * * @author y 2017-8-1 */
public class Test {public static void main(String[] args) { byte b1 = 1, b2 = 2, b3;final byte b4 = 4, b5 = 6, b7;// b1 + b2 结果自动升级为int类型// b3 = b1 + b2; // Errot:cannot convert from int to byte// 当2个final修饰相操作时,结果会根据左边变量的类型.....b7 = b4 + b5; // 语句2;// System.out.println(b3);System.out.println(b7);char a = 'a', b = 'b', c;final char m = 'a', n = 'b', p;// c = a + b; // Error: cannot convert from int to charp = m + n;// System.out.println(c);System.out.println(p);short x = 1, y = 2, z;final short x1 = 1, y1 = 2, z1; //z = x + y;// Error: cannot convert from int to short z1 = x1 + y1; //System.out.println(z); System.out.println(z1);}}
阅读全文
0 0
- byte、char、short运算
- byte,short,char类型的运算
- byte/short/char
- java中byte,short,char,int,long运算
- Java中涉及byte、short和char类型的运算操作
- Java中涉及byte、short和char类型的运算操作
- java对byte,short,char,int,long运算时自动类型转化情况说明
- java对byte,short,char,int,long运算时自动类型转化情况说明
- char,byte或者short进行移位处理
- byte、short、char和int的转换
- byte char short long float double理解
- char, unsigned char = BYTE; short, unsigned short = WORD; long, unsigned long = DWORD;
- java 彻底理解 byte char short int float long double
- 关于java中char,byte,short的移位操作
- java 彻底理解 byte char short int float long double
- 关于java中char,byte,short的移位操作
- java中char,byte,short的移位操作
- java 彻底理解 byte char short int float long double
- 修改pl/sql developer 的编码
- 遮罩ClippingNode
- 解决8080端口占用问题
- Makefile编写详解
- expdp network_link 命令备份远程主机上Oracle 11g数据库
- byte、char、short运算
- 2G退网大势已成,物联网的发展又会有什么样的机遇呢?
- 定时器scheduler
- 银联支付出现这个错误Invalid request.
- 对称加密与非对称加密
- 高通Android wifi移植和wifi热点问题总结
- 信息收集(一)
- 2016蓝桥杯国赛 JAVA C组第五题 路径之谜
- Retrofit各个注解的含义及作用