01 2016 档案
摘要:public class Test { String x; public static void main(String[] args) { Test test = new Test(); try { System...
阅读全文
摘要:Exception继承了Throwable,但是它本身是有异常类的父类。RuntimeException:运行时异常Exception->RuntimeException->NullPointExceptionException->RuntimeException->IndexOutOfBounds...
阅读全文
摘要:1.List----有序的collection(序列)与数组的不同:数据类型可以相同可以不同,数组的长度是预先定义好的,集合的长度也是预先定义好的,但是长度会随着元素的增加而增加ArrayListLinkedListVectorpublic class ListTest { publi...
阅读全文
摘要:public class TestMath { public static void main(String[] args) { System.out.println(Math.E); System.out.println(Math.PI); Syst...
阅读全文
摘要:Date Calendarpublic class TestDate { private Date date; Calendar calendar; public TestDate() { //date = new Date(); //Date...
阅读全文
摘要:1.Stringstring类是最终类,不可以有子类package com.demo.pkg1;public class TestString { public static void main(String[] agrs) { // 构造字符串 String na...
阅读全文
摘要:1.包的概念javac Engine.java -d .package:打包,把类文件编译成class文件会把Engine.class 放到com/cindy/pkg1/目录下运行Enginejava com.cindy.pkg1.Enginepackage com.cindy.pkg1;publi...
阅读全文
摘要:1. interface关键字2.接口中的方法全部是抽象方法,不能被实例3.接口中的成员变量: public static final4.当子类实现接口的时候,必须覆盖接口中所有的方法// 接口public interface Person { // 接口中的方法全部是抽象方法,不能被实例 ...
阅读全文
摘要:1. 抽象类声明有abstract2.抽象类中有抽象方法,没有方法体的方法// 抽象类public abstract class Animal { public String name; public Animal(){ } // 抽象方法:没...
阅读全文
摘要:public class Base { /*public Base() { System.out.println("Base 类的初始构造方法"); }*/ public Base(int x) { System.out.println("Bas...
阅读全文
摘要:public class Father { public void print() { System.out.println("Father:print()"); }}public class Son extends Father{ // 方法的覆盖:子类重写父类的同...
阅读全文
摘要:方法的覆盖:子类继承父类,子类重写父类的同名方法。覆盖的原则:1. 方法的参数必须跟父类保持一致2. 子类方法的修饰符的范围必须大于等于父类方法同名的修饰符(public > private)public class Father { public void print() { ...
阅读全文
摘要:继承:子类可以使用父类非私有的成员变量和方法public class Father { public String name; public String bloodType; private int age; public void work() { ...
阅读全文

浙公网安备 33010602011771号