随笔分类 -  Java学习笔记

摘要:package com.Leo.struct;public class DoWhileDemo01 { public static void main(String[] args) { int i = 0; int sum = 0; do { sum += i; i++; }while (i<=10 阅读全文
posted @ 2021-06-09 09:24 Leoyuan 阅读(46) 评论(0) 推荐(0)
摘要:package com.Leo.struct;public class WhileDemo01 { public static void main(String[] args) { //输入0-100 int i = 0; while (i<100){ i++; System.out.println 阅读全文
posted @ 2021-06-09 09:11 Leoyuan 阅读(61) 评论(0) 推荐(0)
摘要:package com.Leo.struct;public class SwitchDemo01 { public static void main(String[] args) { //case 穿透 //switch 匹配一个具体的值 char grade = 'B'; switch (grad 阅读全文
posted @ 2021-06-09 08:44 Leoyuan 阅读(46) 评论(0) 推荐(0)
摘要:package com.Leo.struct;import java.util.Scanner;public class IfDemo02 { public static void main(String[] args) { Scanner scanner = new Scanner(System. 阅读全文
posted @ 2021-06-08 22:28 Leoyuan 阅读(37) 评论(0) 推荐(0)
摘要:package com.Leo.struct;//顺序结构public class Demo01 { public static void main(String[] args) { System.out.println("hello1"); System.out.println("hello2") 阅读全文
posted @ 2021-06-08 21:40 Leoyuan 阅读(21) 评论(0) 推荐(0)
摘要:package com.Leo.scanner;import java.util.Scanner;public class Demo04 { public static void main(String[] args) { Scanner scanner = new Scanner(System.i 阅读全文
posted @ 2021-06-08 14:17 Leoyuan 阅读(45) 评论(0) 推荐(0)
摘要:package com.Leo.scanner;import java.util.Scanner;public class Demo01 { public static void main(String[] args) { //创建一个扫描对象,用于接受键盘数据 Scanner scanner = 阅读全文
posted @ 2021-06-08 13:35 Leoyuan 阅读(32) 评论(0) 推荐(0)
摘要:package com.Leo.base;/** * @author Leo * @version 1.0 * @since 1.8 */public class Doc { String name; /** * @authour Leo * @param name * @return * @thr 阅读全文
posted @ 2021-06-07 13:27 Leoyuan 阅读(44) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-07 13:06 Leoyuan 阅读(21) 评论(0) 推荐(0)
摘要:package operator;//三元运算符public class Demo08 { public static void main(String[] args) { // x ? y : z //如果x==true,则结果为y,否则结果为z int score = 80; String ty 阅读全文
posted @ 2021-06-07 12:52 Leoyuan 阅读(54) 评论(0) 推荐(0)
摘要:package operator;//逻辑运算符public class Demo05 { public static void main(String[] args) { // 与(and) 或(or) 非(取反) boolean a = true; boolean b = false; Syst 阅读全文
posted @ 2021-06-07 12:14 Leoyuan 阅读(50) 评论(0) 推荐(0)
摘要:package operator;public class Demo04 { public static void main(String[] args) { //++ -- 自增,自减 一元运算符 int a = 3; int b = a++; //执行完这行代码后,先给b赋值,再自增 //a = 阅读全文
posted @ 2021-06-07 12:10 Leoyuan 阅读(57) 评论(0) 推荐(0)
摘要:package operator;public class Demo01 { public static void main(String[] args) { //二元运算符 //Ctrl + D :复制当前行到下一行 int a = 10; int b = 20; int c = 25; int 阅读全文
posted @ 2021-06-07 11:18 Leoyuan 阅读(34) 评论(0) 推荐(0)
摘要://变量public class Demo05 { public static void main(String[] args) { //int a, b, c; //int a=1,b=2,b=3; //程序的可读性 String name = "Leo"; char x = 'X'; doubl 阅读全文
posted @ 2021-06-06 23:55 Leoyuan 阅读(48) 评论(0) 推荐(0)
摘要://类型转换 public class Demo04 { public static void main(String[] args) { int i = 128; byte b = (byte) i;//内存溢出 //强制转换 (类型)变量名 高--低 //自动转换 低———高 System.ou 阅读全文
posted @ 2021-06-06 23:20 Leoyuan 阅读(49) 评论(0) 推荐(0)
摘要:public class Demo03 { public static void main(String[] args) { //整数拓展: 进制 二级制0b 十进制 八进制0 十六进制0x int i= 10; int i2 = 010;//八进制0 int i3 = 0x10;//十六进制0x 阅读全文
posted @ 2021-06-06 16:27 Leoyuan 阅读(40) 评论(0) 推荐(0)
摘要://数据类型 public class Demo02 { public static void main(String[] args) { //八大基本数据类型 //整数 int num1 = 100;//最常用 byte num2 = 20; short num3 = 30; long num4 阅读全文
posted @ 2021-06-06 15:24 Leoyuan 阅读(43) 评论(0) 推荐(0)
摘要://标识符 public class Dome01 { public static void main(String[] args) { //所有的标识符都应该以字母(A-Z或者a-z),美元字符($),或者下划线(_)开始 String Ahello = "leo"; String hello = 阅读全文
posted @ 2021-06-06 15:04 Leoyuan 阅读(48) 评论(0) 推荐(0)
摘要://注释//注释并不会被执行//书写注释是一个非常好的习惯,平时写代码一定要注意规范/** java中的注释有三种* 多行注释* 多行注释* 文档注释*/public class HelloWorld { public static void main(String[] args) { //单行注释 阅读全文
posted @ 2021-06-06 14:36 Leoyuan 阅读(47) 评论(0) 推荐(0)