摘要: if结构 package com.struct; //if单选择结构 import java.util.Scanner; public class IfDemo01 { public static void main(String[] args) { Scanner scanner = new Sc 阅读全文
posted @ 2021-06-01 23:32 颂溪庄 阅读(104) 评论(0) 推荐(0)
摘要: DoWhile结构 package com.struct; public class DoWhile01 { public static void main(String[] args) { ////计算 1+2+3+...+100=? int i = 0; int sum = 0; do{ sum 阅读全文
posted @ 2021-06-01 23:30 颂溪庄 阅读(89) 评论(0) 推荐(0)
摘要: while结构 package com.struct; //while循环 public class WhileDemo01 { public static void main(String[] args) { //输出1~100 int i = 0; while (i<100){ i++; Sys 阅读全文
posted @ 2021-06-01 23:29 颂溪庄 阅读(50) 评论(0) 推荐(0)
摘要: 顺序结构 package com.struct; public class SequenceDemo01 { public static void main(String[] args) { System.out.println("hello01"); System.out.println("hel 阅读全文
posted @ 2021-06-01 23:25 颂溪庄 阅读(35) 评论(0) 推荐(0)
摘要: 输入scanner 1.next() package com.scanner; import java.util.Scanner; /** * next(); * 一定要读取到有效字符后才可以结束输入, * next();不能得到带有控格的字符串。 * 对输入有效字符之前遇到的空格,会自动将其去掉。 阅读全文
posted @ 2021-06-01 10:08 颂溪庄 阅读(593) 评论(0) 推荐(0)
摘要: 运算操作2 1,自增 自减 package operator; public class Demo04 { public static void main(String[] args) { //++ -- 自增 ,自减 一元运算符 int a = 3; int b = a++; int c = ++ 阅读全文
posted @ 2021-05-28 17:36 颂溪庄 阅读(68) 评论(0) 推荐(0)
摘要: 运算操作 package operator; public class Demo01 { public static void main(String[] args) { // 二元运算 // Ctrl + D :复制当前行到下一行 int a = 10; int b = 20; int c = 2 阅读全文
posted @ 2021-05-28 16:12 颂溪庄 阅读(73) 评论(0) 推荐(0)
摘要: 变量 package base; public class Demo08 { //属性:变量 //类变量 static static double salary = 2500; // 实例变量,从属于对象; //如果不自行初始化,这个类型的默认值 0 // 布尔值:默认值false // 除了基本类 阅读全文
posted @ 2021-05-28 16:10 颂溪庄 阅读(59) 评论(0) 推荐(0)
摘要: //实例,操作较大数字的时候,注意溢出问题 //JDK7新特性,数字之间可以用下划线分割 int money = 1_0000_0000; int year = 20; int total1 = money*year; //-1474836480 ,计算的时候int类型溢出了 long total2 阅读全文
posted @ 2021-05-26 15:14 颂溪庄 阅读(85) 评论(0) 推荐(0)
摘要: 类型转换 数据类型由低到高: byte,short,char,int,long,float,double int i = 128; byte b = (byte)i; //内存溢出(byte:0-127) System.out.println(i); System.out.println(b); S 阅读全文
posted @ 2021-05-26 15:13 颂溪庄 阅读(61) 评论(0) 推荐(0)