06 2021 档案

摘要:package com.exception.demo02;//自定义异常类public class MyException extends Exception{ //传递数字>10; private int detail; public MyException(int a) { this.detai 阅读全文
posted @ 2021-06-14 18:56 Leoyuan 阅读(72) 评论(0) 推荐(0)
摘要:package com.oop.exception;public class Test { public static void main(String[] args) { try { new Test().test(1,0); } catch (ArithmeticException e) { e 阅读全文
posted @ 2021-06-13 11:01 Leoyuan 阅读(74) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-13 09:58 Leoyuan 阅读(77) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo10.Outer;public class Application { public static void main(String[] args) { Outer outer = new Outer(); //通过外部类来实例化 阅读全文
posted @ 2021-06-13 09:28 Leoyuan 阅读(71) 评论(0) 推荐(0)
摘要:package com.oop.demo09;//抽象的思维~java//interface 定义的关键字, 接口都需要有实现类public interface UserService { //常量 public static final int AGE = 99; //接口中的所有的定义其实都是抽 阅读全文
posted @ 2021-06-12 18:39 Leoyuan 阅读(76) 评论(0) 推荐(0)
摘要:package com.oop.demo08;//abstract 抽象类:类 extends: 单继承 (接口可以多继承)public abstract class Action { //约束~有人帮我们实现~ //abstract ,抽象方法,只有方法名字,没有方法的实现! public abs 阅读全文
posted @ 2021-06-12 18:02 Leoyuan 阅读(52) 评论(0) 推荐(0)
摘要:package com.oop.demo07;public class Person { { //2.赋初值 //代码块(匿名代码块) System.out.println("匿名代码块"); } static { //1.只执行一次 //静态代码块 System.out.println("静态代码 阅读全文
posted @ 2021-06-12 17:06 Leoyuan 阅读(58) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo06.Person;import com.oop.demo06.Student;import com.oop.demo06.Teacher;public class Application { public static void 阅读全文
posted @ 2021-06-12 16:36 Leoyuan 阅读(70) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo06.Person;import com.oop.demo06.Student;public class Application { public static void main(String[] args) { //一个对象的 阅读全文
posted @ 2021-06-11 21:43 Leoyuan 阅读(86) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo05.A;import com.oop.demo05.B;;public class Application { //静态的方法和非静态的方法区别很大! //静态方法:方法的调用只和左边,定义的数据类型有关 //非静态方法:重写 阅读全文
posted @ 2021-06-11 18:19 Leoyuan 阅读(57) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo05.Person;import com.oop.demo05.Student;public class Application { public static void main(String[] args) { Student 阅读全文
posted @ 2021-06-11 13:07 Leoyuan 阅读(51) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo05.Student;public class Application { public static void main(String[] args) { Student student = new Student(); stu 阅读全文
posted @ 2021-06-11 07:38 Leoyuan 阅读(51) 评论(0) 推荐(0)
摘要:package com.oop.demo04;//类 private:私有public class Student { //属性私有 private String name; //名字 private int id;//学号 private char sex;//性别 private int age 阅读全文
posted @ 2021-06-11 07:10 Leoyuan 阅读(60) 评论(0) 推荐(0)
摘要:package com.oop;import com.oop.demo03.Pet;public class Application { public static void main(String[] args) { /* 1. 类与对象 类是一个模板:抽象,对象是一个具体的实例 2. 方法 定义 阅读全文
posted @ 2021-06-10 23:23 Leoyuan 阅读(56) 评论(0) 推荐(0)
摘要:package com.oop.demo03;public class Pet { public String name; public int age; //无构造参数 public void shout(){ System.out.println("叫了一声"); }}/* public sta 阅读全文
posted @ 2021-06-10 22:31 Leoyuan 阅读(39) 评论(0) 推荐(0)
摘要:package com.oop.demo02;//java-->classpublic class Person { //一个类即使什么都不写,它也会存在一个方法 //显示的定义构造器 String name; int age; //实例化初始化 //1. 使用new关键字,本质在调用构造器 //2 阅读全文
posted @ 2021-06-10 21:48 Leoyuan 阅读(48) 评论(0) 推荐(0)
摘要:package com.oop.demo02;//一个项目应该只有一个main方法public class Application { public static void main(String[] args) { //类:抽象的,实例化 //类实例化后会返回一个自己的对象! //student对 阅读全文
posted @ 2021-06-10 19:52 Leoyuan 阅读(45) 评论(0) 推荐(0)
摘要:package com.oop.demo01;public class Demo02 { public static void main(String[] args) { //实例化这个类 new //对象类型 对象名 = 对象值; Student student = new Student(); 阅读全文
posted @ 2021-06-10 17:50 Leoyuan 阅读(49) 评论(0) 推荐(0)
摘要:package com.oop.demo01;import java.io.IOException;//Demo01 类public class Demo01 { //main 方法 public static void main(String[] args) { } /* 修饰符 返回值类型 方法 阅读全文
posted @ 2021-06-10 17:17 Leoyuan 阅读(41) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-10 09:03 Leoyuan 阅读(28) 评论(0) 推荐(0)
摘要:package com.Leo.array;public class ArrayDemo08 { public static void main(String[] args) { //1.创建一个二维数组 11* 11 0:没有棋子 1:黑棋 2:白棋 int[][] array1 = new in 阅读全文
posted @ 2021-06-10 08:48 Leoyuan 阅读(55) 评论(0) 推荐(0)
摘要:package com.Leo.array;import java.util.Arrays;//冒泡排序//1. 比较数组中,两个相邻的元素,如果第一个数比第二个数大,我们就交换他们的位置//2. 每一次比较,都会产生一个最大,或者最小的数子;//3. 下一轮则可以少一次排序!//4. 依次循环,直 阅读全文
posted @ 2021-06-10 07:37 Leoyuan 阅读(73) 评论(0) 推荐(0)
摘要:package com.Leo.array;import java.util.Arrays;public class ArrayDemo06 { public static void main(String[] args) { int [] a = {1,2,3,4,9090,31231,543,2 阅读全文
posted @ 2021-06-10 07:08 Leoyuan 阅读(68) 评论(0) 推荐(0)
摘要:package com.Leo.array;public class ArrayDemo05 { public static void main(String[] args) { //[4][2] /* 1,2 array[0] 2,3 array[1] 3,4 array[2] 4,5 array 阅读全文
posted @ 2021-06-10 06:43 Leoyuan 阅读(47) 评论(0) 推荐(0)
摘要:package com.Leo.array;public class ArrayDemo04 { public static void main(String[] args) { int[] arrays = {1,2,3,4,5};//// //JDK1.5 没有下标// for (int arr 阅读全文
posted @ 2021-06-09 23:55 Leoyuan 阅读(57) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-09 23:26 Leoyuan 阅读(82) 评论(0) 推荐(0)
摘要:package com.Leo.array;public class ArrayDemo02 { public static void main(String[] args) { //静态初始化:创建 + 赋值 int[] a = {1,2,3,4,5,6,7,8}; System.out.prin 阅读全文
posted @ 2021-06-09 22:17 Leoyuan 阅读(58) 评论(0) 推荐(0)
摘要:package com.Leo.array;public class ArrayDemo01 { //变量的类型 变量的名字 = 变量的值‘ //数组类型 public static void main(String[] args) { int[] nums;//1.声明一个数组 nums = ne 阅读全文
posted @ 2021-06-09 21:07 Leoyuan 阅读(54) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-09 20:50 Leoyuan 阅读(23) 评论(0) 推荐(0)
摘要:package com.Leo.method;public class Demo05 { public static void main(String[] args) { Demo05 test = new Demo05(); test.test(); } public void test(){ t 阅读全文
posted @ 2021-06-09 20:44 Leoyuan 阅读(51) 评论(0) 推荐(0)
摘要:package com.Leo.method;public class Demo04 { public static void main(String[] args) { //调用可变参数的方法 printMax(34, 3, 3, 2, 56.5); printMax(new double[]{1 阅读全文
posted @ 2021-06-09 20:26 Leoyuan 阅读(55) 评论(0) 推荐(0)
摘要:package com.Leo.method;public class Demo03 { public static void main(String[] args) { //args.Length 数组长度 for (int i = 0; i < args.length;i++){ System. 阅读全文
posted @ 2021-06-09 20:13 Leoyuan 阅读(54) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-09 19:55 Leoyuan 阅读(19) 评论(0) 推荐(0)
摘要:package com.Leo.method;public class Demo02 { public static void main(String[] args) { int max = max(10, 20); System.out.println(max); } //比大小 public s 阅读全文
posted @ 2021-06-09 19:43 Leoyuan 阅读(67) 评论(0) 推荐(0)
摘要:package com.Leo.method;public class Demo01 { //main 方法 public static void main(String[] args) { //int sum = add(1,2); //System.out.println(sum); test( 阅读全文
posted @ 2021-06-09 19:03 Leoyuan 阅读(55) 评论(0) 推荐(0)
摘要:package com.Leo.struct;public class TestDemo { public static void main(String[] args) { //打印三角形 5行 for (int i = 1; i <= 5; i++) { for (int j = 5; j >= 阅读全文
posted @ 2021-06-09 18:38 Leoyuan 阅读(48) 评论(0) 推荐(0)
摘要:package com.Leo.struct;public class BreakDemo { public static void main(String[] args) { int i = 0; while (i<100){ i++; System.out.println(i); if (i== 阅读全文
posted @ 2021-06-09 17:33 Leoyuan 阅读(55) 评论(0) 推荐(0)
摘要:package com.Leo.struct;public class ForDemo05 { public static void main(String[] args) { int[] numbers = {10,20,30,40,50};//定义一个数组 for (int i = 0; i < 阅读全文
posted @ 2021-06-09 17:03 Leoyuan 阅读(60) 评论(0) 推荐(0)
摘要:package com.Leo.struct;/*1*1=12*1=2 2*2=43*1=3 3*2=6 3*3=94*1=4 4*2=8 4*3=12 4*4=165*1=5 5*2=10 5*3=15 5*4=20 5*5=256*1=6 6*2=12 6*3=18 6*4=24 6*5=30 阅读全文
posted @ 2021-06-09 13:39 Leoyuan 阅读(60) 评论(0) 推荐(0)
摘要:package com.Leo.struct;public class ForDemo01 { public static void main(String[] args) { int a = 1;//初始化条件 while (a<=100){//条件判断 System.out.println(a) 阅读全文
posted @ 2021-06-09 13:24 Leoyuan 阅读(108) 评论(0) 推荐(0)
摘要: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 阅读(50) 评论(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 阅读(65) 评论(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 阅读(52) 评论(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 阅读(38) 评论(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 阅读(51) 评论(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 阅读(36) 评论(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 阅读(53) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-07 13:06 Leoyuan 阅读(22) 评论(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 阅读(60) 评论(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 阅读(51) 评论(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 阅读(59) 评论(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 阅读(36) 评论(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 阅读(57) 评论(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 阅读(55) 评论(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 阅读(47) 评论(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 阅读(44) 评论(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 阅读(57) 评论(0) 推荐(0)
摘要://注释//注释并不会被执行//书写注释是一个非常好的习惯,平时写代码一定要注意规范/** java中的注释有三种* 多行注释* 多行注释* 文档注释*/public class HelloWorld { public static void main(String[] args) { //单行注释 阅读全文
posted @ 2021-06-06 14:36 Leoyuan 阅读(53) 评论(0) 推荐(0)