随笔分类 -  Java学习笔记

摘要: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 阅读(68) 评论(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 阅读(69) 评论(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 阅读(63) 评论(0) 推荐(0)
摘要:package com.oop.demo09;//抽象的思维~java//interface 定义的关键字, 接口都需要有实现类public interface UserService { //常量 public static final int AGE = 99; //接口中的所有的定义其实都是抽 阅读全文
posted @ 2021-06-12 18:39 Leoyuan 阅读(69) 评论(0) 推荐(0)
摘要:package com.oop.demo08;//abstract 抽象类:类 extends: 单继承 (接口可以多继承)public abstract class Action { //约束~有人帮我们实现~ //abstract ,抽象方法,只有方法名字,没有方法的实现! public abs 阅读全文
posted @ 2021-06-12 18:02 Leoyuan 阅读(50) 评论(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 阅读(51) 评论(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 阅读(64) 评论(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 阅读(82) 评论(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 阅读(53) 评论(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 阅读(48) 评论(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 阅读(49) 评论(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 阅读(56) 评论(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 阅读(51) 评论(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 阅读(36) 评论(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 阅读(44) 评论(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 阅读(39) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2021-06-10 09:03 Leoyuan 阅读(28) 评论(0) 推荐(0)