摘要: 执行结果截图: 代码: public class HelloWorld { public static void main(String[] args) { // 编码规范————到百度搜:阿里巴巴java开发手册 // 按住ctrl键再按/可以打出// /* 如果事先在IDEA的settings- 阅读全文
posted @ 2021-12-14 21:41 JohnnyH 阅读(407) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class MandatoryConvert { public static void main(String[] args) { int i1 = 128; // int强制转换为byte(高容量转低容量)是强制转换,但是可能导致内存溢出 byte b = ( 阅读全文
posted @ 2021-12-14 04:18 JohnnyH 阅读(1624) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class TernaryOperator { public static void main(String[] args) { int a = 10; int b = 20; // a += b 与 a=a+b的区别:前者的+=带自动强制转换数据类型,后者如果 阅读全文
posted @ 2021-12-14 04:07 JohnnyH 阅读(1355) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class UnaryOperator { public static void main(String[] args) { int x = 2; int y = 1; int z = 3; // 单目运算符 ++ -- ~ ! /* 分解来看,步骤1:表达式- 阅读全文
posted @ 2021-12-13 15:09 JohnnyH 阅读(384) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class PublicStaticFinal { /* 修饰符(静态static、常量final)不存在先后顺序,常量可以理解为特殊的变量,适合定义不会变的量。 常量名要全用大写,用final修饰符后,只允许常量被定义一次(静态常量) */ static fi 阅读全文
posted @ 2021-12-12 06:32 JohnnyH 阅读(61) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class ClassScopes { /* Java程序在内存中的存储分配情况: 一、堆区、栈区、方法区 堆区: 1.存储的全部是对象,每个对象都包含一个与之对应的class的信息。(class的目的是得到操作指令) 2.jvm只有一个堆区(heap)被所有线 阅读全文
posted @ 2021-12-12 05:36 JohnnyH 阅读(154) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class BitwiseAndShiftOperators { public static void main(String[] args) { // 位运算,不要轻易使用位运算,很容易出错 // 十进制的60用二进制表示为0011 1100, 即32+16+ 阅读全文
posted @ 2021-12-11 17:36 JohnnyH 阅读(117) 评论(0) 推荐(0)
摘要: 执行结果截图 代码: public class LogicalOperator { public static void main(String[] args) { // 与(and) 或(or) 非(取反) boolean a = true; boolean b = false; System.o 阅读全文
posted @ 2021-12-11 13:00 JohnnyH 阅读(95) 评论(0) 推荐(0)
摘要: 输出结果截图: 代码: public class BinaryOperator { public static void main(String[] args) { // 二元运算符 // 快捷键操作:ctrl+D ————复制当前行到下一行 // 赋值运算符优先级最低 int a1 = 10; i 阅读全文
posted @ 2021-12-11 12:57 JohnnyH 阅读(796) 评论(0) 推荐(0)
摘要: 执行结果截图: 代码: public class DataType { public static void main(String[] args) { String name = "汤姆·克鲁斯"; int kill = 99; String title = "‘一竿走天涯’"; // 以下使用格 阅读全文
posted @ 2021-12-04 13:26 JohnnyH 阅读(137) 评论(0) 推荐(0)