码迷,mamicode.com
首页 > 编程语言 > 详细

javaSE总结

时间:2021-02-20 12:35:14      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:最快   否则   err   aot   pack   query   load   row   数组   

javaSE总结

Hello world

public class Hello{
	public static void main(String[] args){
		System.out.print("Hello,World!");
	}
}

编译: javac Hello.java

运行: java Hello


注释

public class HelloWorld {
    public static void main(String[] args) {
        //输出一个hi,world
        //单行注释

        /*   我是
        多行注释
        注释,随便写
         */

        /**我是文档注释
         * @Description Helloworld
         * @Author
         */        
    }
}

标识符和关键字

 String Apple = "ios";
 String apple = "ios";
 String $apple = "ios";
 String _apple = "ios";
//标识符可以大小写,$,_,开头
//非法开头:数字,#,*,%

数据类型

public class Hello {
    public static void main(String[] args) {
        //整数拓展: 进制  二进制0b 十进制 八进制0 十六进制0x
        int i = 10;
        int i2 =0b100;
        int i3 =010;//八进制
        int i4 =0x10;//十六进制 0~9 A~F
        
        char name = ‘严‘; //注意只能对应一个汉字,对应符为 ‘
        char c1 =‘a‘;
        char c2 =‘\u2314‘;  // 转义字符(十六进制)
        System.out.println((int)c1);//强制转换
        //所有的字符本质还是数字    
    }

类型转换

public class dome01 {
    public static void main(String[] args) {
        int i=128;
        byte b = (byte)i;//内存溢出
        //强制转换  (类型)变量名  高-低
        //自动转换  低-高
        //运行中,不同类型数据转化为同一类型
        
        char c = ‘a‘;
        int d = c+1;//原c定义a转换为U码再进行加一
        System.out.println(d);//输出为U码
        System.out.println((char) d);//强制转换
    }
}

变量,常量,作用域

public class dome01 {
    //常量,使用final命名大写,大写字母和下划线:MAX_VALUE
    static final double PT = 3.14159;   
    
    public static void main(String[] args) {
        
        int a=1,b=2,c=3;
        //别这么定义,可读性差
        String name ="xiaoyan";
        char x =‘x‘;
        double pai =3.14;  
    }    
}
//作用域
public class Doem01 {
    String skr = "hello,world";//实例变量:从属于对象
    static int allClicks = 0;//类变量,static可直接引用       
    public static void main(String[] args) {
        int i = 01;//局部变量:必须声明和初始化值
        //数值类型初始化都是0或0.0
        //除了基本类型其余都是null
        //布尔值:默认为false
    }
}

运算符

public class Demo01 {
    public static void main(String[] args) {
        //二元运算符
        int a = 10;
        int b = 20;

        System.out.println(a+b);
        System.out.println(a-b);
        System.out.println(a*b);
        System.out.println(a/b);//无法正确计算结果,因为int值算出结果为int类直接省略小数
        System.out.println(a/(double)b);//可以输出正确结果
        System.out.println(d%a);//d取余a,d模运算a
        
        long a = 1212121212L;
        int b = 128;
        short c = 10;
        byte d = 6;

        System.out.println(a+b+c+d);//有long类型转换为long类型
        System.out.println(b+c+d);//默认int
        System.out.println(c+d);//默认int
        System.out.println(d);//默认int
        //即使是低位也默认int,小数double同理
        //检验方法:string低位相加结果 string无法标识int结果 
         
        //++  -- 自增  自减  一元运算符
        int a = 3;
        int b = a++;//先执行代码给b赋值,再自增,a=a+1
        int c = ++a;//先给a自增,再给c赋值


        //幂运算: 2^3  2*2*2 =8,,很多运算需要工具类来操作
        double pow = Math.pow(2,3);
        
        // x ? y:z 三元运算符
        //如果x为真,结果为y否则为z
        int score = 80;
        String type = score <60 ? "不及格":"及格";
        System.out.println(type);//输出及格
        
          /* 
        位运算
        A = 0011 1100
        B = 0000 1101
        
        A&B 0000 1100 (交集,都为1则为1,否为0)
        A/B 0011 1101 (并集,有1则1)
        A^B 0011 0001 (取反,如果相同为零,不同为1)
        ~B 1111 0010 (取反1为0,0为1)
        
        2*8 = 16 2*2*2*2
        << 左移相当于原本的数*2  
        >> 右移相当于原本的数/2
        0000 0000  0
        0000 0001  1
        0000 0010  2
        0000 0011  3
        0000 0100  4
        0000 1000  8
        0001 0000  16     
         */
        
     
        int a =10;
        int b =20;
        a+=b;//a=a+b
        a-=b;//a=a-b
        //字符串链接符 + ,string
        System.out.println("123"+a+b);//是字符连接串的效果输出为1231020
        System.out.println(a+ b+ "123");//前面是加法后面""内容为文本,输出为30123       
    }
}

用户交互Scanner

Scanner s = new Scanner(System.in);
import java.sql.SQLOutput;
import java.util.Scanner;

public class Dome {
    public static void main(String[] args) {
        //创建一个扫描器对象,从键盘接收
        Scanner scanner = new Scanner(System.in);
        System.out.println("使用next方式接收:");
        
        if (scanner.hasNext()){ //判断用户有没有输入字符串,用next接收输入           
            String str =scanner.next();//Next接收信息有 就停止输入,NextLine可以接收Enter前的所有字符
            System.out.println("输出的内容为:"+str);            
        }else{
            System.out.println("非法输入");
        }    
        scanner.close();//凡是属于IO流的类,用完一定要关掉,不然会一直占资源
    }
}

选择结构

import java.util.Scanner;

public class Dome01 {
    public static void main(String[] args) {
        //if
        System.out.println("请输入成绩:");
        Scanner scanner = new Scanner(System.in);
        int score = scanner.nextInt();

        if (score==100){
            System.out.println("满分");
        }else if (score<100 && score>=60){
            System.out.println("及格");
        }else if (score<60 && score>=60){
            int s =60-score;
            System.out.println("您没有及格,还差"+s+"分");
        }else {
            System.out.println("成绩不合法");//不包含内容
        }
        scanner.close();
    }
}

多选择结构

public class Switch {
    public static void main(String[] args) {

        char grade=‘B‘;

        switch(grade){
            case ‘A‘:
                System.out.println("excellent");
                break;//终止
            case ‘B‘://如果是B则之后的结果都会出来,case穿透
                System.out.println("Good");
            case ‘C‘://每写一个case都把break加上
                System.out.println("pass");
            default://都不是
                System.out.println("not such level fould");             
        }
    }

循环结构

public class Mod01 {
    public static void main(String[] args) {
        
        int i = 0;
        
        while (i<0){
            i++;
            System.out.println("The is one");
        }
        do {
            i++;//至少会执行一次
            System.out.println("The is two");
        }while (i<0);
    }
}

for 循环

public class ForDemo01 {
    public static void main(String[] args) {
        
        int a = 1;//初始化条件
        while (a<=100){//条件判断
            System.out.println(a);//循环体
            a+=2;//迭代
        }
        System.out.println("while 结束");

        //   初始化条件//条件判断//迭代
        //100.for 快捷键生成
        for (int i=1;i<=100;i++){
            System.out.println(i);
        }
        System.out.println("for 结束");
        for (int i = 0; i < 100; i++) {
        }
    }
}

增强型的for循环

public class Demo07 {
    public static void main(String[] args) {
        
        int[] number = {10,20,30,40};//定义了一个数组
        //遍历数组中的元素
        for (int x:number){
            System.out.println(x);
        }
        for (int i =0;i<5;i++){
            System.out.println(number[i]);
        }
    }
}

break continue

break用于强行退出循环,不执行循环中剩余的语句。

continue用于终止某次循环过程,即跳过循环体中尚未执行的语句,接着进行下一次是否执行循环的判定。

public class liucheng {
    public static void main(String[] args) {
        
        int i = 0;
        
        while(i<100){
            i++;
            if (i%10==0){
                System.out.println();
                continue;//跳过一个循环
            }
            System.out.print(i);
        }
    }
}

方法的定义和调用

import java.security.spec.RSAOtherPrimeInfo;

public class Demo02 {
    public static void main(String[] args) {       
        int i = compare(40, 77);
        System.out.println(i);
    }

    public static int compare(int num1,int num2){
        int result = 0;

        if (num1==num2){
            System.out.println("num1==num2");
            return 0;//return可终止方法
        }

        if (num1>num2){
            result = num1;
        }else{
            result = num2;
        }
        return result;//如果存在返回值一定要用return返回
    }
}

?

可变参数

  1. 指定参数类型后加一个省略号(.).
  2. 只能指定一个可变参数
  3. 必须是方法的最后一个参数,任何普通的参数必须在它之前声明。
public class Demo04 {
    public static void main(String[] args) {
        //调用可变参数的方法
        printMax(34,12,35,52,66,55,13,77,12);
        printMax(new double[]{1,2});

    }

    public static void printMax(double... number){
        if (number.length == 0){
            System.out.println("No argument passed");
            return;
        }
        double result = number[0];
        //排序
        for (int i = 1; i < number.length; i++) {
            if (number[i]> result){
                result = number[i];
            }
            System.out.println("The max value is"+result);
        }      
    }
}

递归

递归结构包括两个部分:

  1. 递归头:什么时候不调用自身方法。如果没有头,将陷入死循环。
  2. 递归体:什么时候需要调用自身方法。
public class Demo05 {
    public static void main(String[] args) {
        Demo05 demo05 = new Demo05();
        demo05.test();
    }

    public static void test() {
        test();
        //死循环,错误的
    }
}

public class Demo06 {
    //阶乘 5! 5*4*3*2*1
    //3! 3*2*1
    public static void main(String[] args) {
        System.out.println(f(16));

    }
    public static int f(int n) {
        if (n == 1) {
            return 1;
        } else {
            return n*f(n-1);
        }
    }
}

数组

  1. 数组是相同类型数据的有序集合。
  2. 数组描述的是相同类型的若干个数据,按照一定的先后次序排列组合而成。其中,每一个数据称作一个数组元素,每个数组元素可以通过一个下标来访向它i们
//初始化
public class Demo {    
    public static void main(String[] args) {
        //静态初始化 创建并赋值
        int[] a = {3,4,5,6,7,5,1,23,5};
        //动态初始化 包含默认初始化
        int[] b = new int[10];
        b [0]=10;
    }
}
public class Demo01 {
    public static void main(String[] args) {
        int[] nums; //申明数组,没分配空间
        nums = new int[10];//创建数组,可以存放十个类型的数字
        
        int[] nums02 = new int[25];//省略写法

        //给数组赋值,没赋值就是默认值
        nums[0] = 1;
        nums[1] = 2;
        nums[2] = 3;
        nums[3] = 4;
        nums[4] = 5;
        nums[5] = 6;
        
        //计算所有元素的和
        int sum = 0;
        //获取数组长度: arrays.length
        for (int i = 0; i < nums.length; i++) {
            sum = sum + nums[i];
            System.out.println(sum);
        }
    }
}

数组的使用

public class Demo02 {
    public static void main(String[] args) {
        int []  array= {0,123,456,654,789,158,321,456,258 }  ;
        
        //打印全部元素
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
        //查找最大的元素
        int max = array[0];
        for (int i = 0; i < array.length; i++) {
            if (array[i]>max){
                max = array[i];
            }
        }
        System.out.println(max);
    }
}
public class Demo03 {
    public static void main(String[] args) {
        int [] array = {0,1,2,3,4,5};

        //没有下标,jdk1.5
        for (int i : array) {
            System.out.println(i);

        }

        printArray(array);
        int[] reverse = reverse(array);
        printArray(reverse);
    }
    //打印数组
    public static void printArray(int[] array){
        for (int i = 0;i < array.length;i++){
            System.out.println(array[i]+"");
        }

    }
    //反转数组
    public static int [] reverse(int[] arrays){
        int[] result =new int[arrays.length];

        for (int i = 0,j=result.length-1;i < arrays.length; i++,j--) {
            result[j]=arrays[i];
        }
        return result;
    }
}

冒泡排序

import java.util.Arrays;

public class Demo04 {
    public static void main(String[] args) {
        int[] array = {1,56,34,48,56,34,78,88,25};

        //依次比较大小如果比较大则交换位置
        //每次比较都会产生有个最大,或最小的数字
        //下一轮少一次排序
        //依次循环知道结束

        int[] sort = sort(array);
        System.out.println(Arrays.toString(sort));

    }
    public static int[] sort(int[] arrays){
        int temp = 0;

        //外层循环
        for (int i = 0; i < arrays.length; i++) {
            //内循环,比较两个数,如果第一个数比第二个大则交换位置
            for (int j = 0; j < arrays.length-1-i; j++) {
                if (arrays[j+1]>arrays[j]){
                    temp = arrays[j];
                    arrays[j] = arrays[j+1];
                    arrays [j+1] = temp;
                }
            }
        }
        return arrays;
    }
}

稀疏数组

public class Demo05 {
    public static void main(String[] args) {

        int[][] array = new int[11][11];
        array[1][2] = 1;
        array[2][3] = 2;

        System.out.println("输出的原始数据");

        for (int[] ints : array) {
            for (int anInt : ints){
                System.out.print(anInt+"\t");
            }
            System.out.println();

        }

        //转换为稀疏数组
        //获取有效值的个数
        int sum = 0;
        for (int i = 0; i < 11; i++) {
            for (int j = 0; j < 11; j++) {
                if (array[i][j]!=0){
                    sum++;
                }
            }
            
        }
        System.out.println("有效值个数"+sum);

        //创建稀疏数组的数组
        int[][] ints = new int[sum + 1][3];
        ints[0][0]=11;
        ints[0][1]=11;
        ints[0][2]=sum;

        int count = 0;

        //遍历二维数组存放在稀疏数组中
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                if (array[i][j]!=0){
                    count++;
                    ints[count][0]=i;
                    ints[count][1]=j;
                    ints[count][2]=array[i][j];
                }
            }
        }
        //输出稀疏数组
        System.out.println("输出稀疏数组");
        for (int i = 0; i < ints.length; i++) {
            System.out.print(ints[i][0]+"\t"
                    +ints[i][1]+"\t"
                    +ints[i][2]+"\n");

        }

        //输出稀疏数组
        int[][] ints1 = new int[ints[0][0]][ints[0][1]];
        
        //还原其中元素的值
        for (int i = 1; i < ints.length; i++) {
            ints1[ints[i][0]][ints[i][1]] = ints[i][2];
        }
        System.out.println("还原的数组");

        for (int[] ints2 : ints1) {
            for (int anInt : ints2) {
                System.out.print(anInt+"\t");
            }
            System.out.println();
        }
    }
}

类和对象

public class Demo01 {

    //属性:字段
    String name;
    int age;

    //方法
    public  void  study(){
        System.out.println(this.name+"在学习");
    }

}
public class Application {
    public static void main(String[] args) {

        Demo01 xiaoming = new Demo01();
        Demo01 xiaoyan = new Demo01();
        //实例化以后会返回一个自己的对象

        xiaoming.name = "小明";
        xiaoming.age = 3;

        System.out.println(xiaoming.name);
        System.out.println(xiaoming.age);

        xiaoyan.name = "小言";
        xiaoyan.age = 5;

        System.out.println(xiaoyan.name);
        System.out.println(xiaoyan.name);

    }
}

构造器

public class Demo02 {
    //一个类型什么都不写,它也会存在一个方法,构造方法
    // public Demo02(){ }  
    String name;

    //实例化的初始值
    //方法名和类名相同
    //没有返回值也不能写void
    //使用new必须有构建器,new一个对象实质是在调一个构造器

    //有参构造 一旦定义了有参构造,无参必须显示定义
    public Demo02(String name){
        this.name = name;
    }
}
public class total {
    public static void main(String[] args) {

        Demo02 demo02 = new Demo02("xiaoyan");

        System.out.println(demo02.name);
    }
}

方法调用

import com.array.Demo;

public class Demo01 {
    public static void main(String[] args) {
        Demo02 i = new Demo02();
        //调用类,然后可以直接调用类下的方法,把类赋给对象
        i.say();//调用对象

        String s = new Demo01().sayHello();
        System.out.println(s);

    }
    //修饰符 返回值类型 方法名() {
    //方法体
    //return 结束方法返回结果
    public String sayHello(){
        return "hello,world";
    }
}
public class Demo02 {
    //定义一个方法
    public void say(){
        System.out.println("学生说话了");
    }
    //static和类一起加载
    public static void a(){
    }
    //动态,实例化之后才存在,
    public void b(){
    }//所以同一类下的两个方法同静态或动态都可相互调用,但不同类无法调用
}
//值传递
public class Demo03 {
    public static void main(String[] args) {
        int a = 0;
        System.out.println(a);
        changer(a);
        System.out.println(a);//输出还是0
    }
    //返回值为空
    public static void changer(int a) {
        a=10;
    }
}
//引用传递: 对象,本质还是值传递
public class Demo04 {
    public static void main(String[] args) {
        Perosn perosn = new Perosn();

        System.out.println(perosn.name);//输出一个null

        Demo04.change(perosn);

        System.out.println(perosn.name);
    }

    public static void change(Perosn perosn) {
        perosn.name = "小言";
    }

}
//定义了一个Perosn类,有一个属性name
class Perosn{
    String name;
}

创建对象内存分析

技术图片


封装

public class test01 {
    //privat 类 私有类
    private String name;
    private  int age;
    private  char sex;

    //get 获取 set 设置
    //在引用中中创造一个public类
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    //alt insScrlk 自动生成方法
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        if (age<120 && age>0){
            this.age = age;
        }else{
            this.age = 3;//可以用封装进行数据判断,筛出无用条件
        }
    }
    public char getSex() {
        return sex;
    }
    public void setSex(char sex) {
        this.sex = sex;
    }
    
    
    public static void main(String[] args) {

        test01 t1 = new test01();
        t1.setName("小言");

        System.out.println(t1.getName());

        t1.setAge(255);
        System.out.println(t1.getAge());

        t1.setAge(18);
        System.out.println(t1.getAge());

    }

}

继承

//学生也属于人
public class Student extends Person{
    //用extends继承,派生类,子类
    Person person;//组合方法,把Person的方法拿过来用
    //public 公共的
    //protected 受保护的
    //private 私有的没法继承父类的
    //default 默认的
    //Ctrl + H 打开继承树
     public static void main(String[] args) {
        Person person = new Person();
        //即使是空类也有默认方法
        //java所有类都直接或间接继承object
    }
}

super

public class Student extends Person{
    //相当于有个隐藏的super条件,切该条件不能至下
    //调用父类代码必须在第一行
    public Student(){
        System.out.println("Student无参执行");
    }

    private String name = "kirret";

    public void test(String name){
        System.out.println(name);
        System.out.println(this.name);
        System.out.println(super.name);//上一级的name
    }
}
public class Person {

    protected String name = "小言";

    public Person(){
        System.out.println("Person无参执行");
    }
}
public class total {
    public static void main(String[] args) {
        Student student = new Student();
        student.test("you are sb");
        Student student1 = new Student();

    }
}

重写

public class total {
    public static void main(String[] args) {
        Student student = new Student();
        student.Test();

        Person person = new Student();//静态下子类重写了父类的方法
        person.Test();//父类的引用指向子类

    }
}
public  class Person {
    public static void Test(){
        System.out.println("这是父类");
    }
}
public  class Student extends Person{
    public static void Test(){
        System.out.println("这是子类");
    }
}

instanceof

public class total {
    public static void main(String[] args) {
        Student student = new Student();
        //System.out.println(x instanceof y);x和y是否有父子关系
        System.out.println(student instanceof Student);
        System.out.println(student instanceof Person);
        System.out.println(student instanceof Object);
    }
}
public class total {
    public static void main(String[] args) {

      Person  student = new Student();
      student.Test02();//可以直接引用

        ((Student)student).Test01();
        //强制转换高转低


    }
}

static 修饰符

public  class Student {
    private static int age;//静态变量
    private double score;//非静态变量
 
    public static void main(String[] args) {
        Student student = new Student();
        System.out.println(Student.age);//类变量
        //System.out.println(Student.score);非静态没法类调用
        System.out.println(student.age);
        System.out.println(student.score);
    }
}
public  class Student {
    private static int age;//静态变量
    private double score;//非静态变量
    public void run(){

    }
    public static void go(){

    }
    public static void main(String[] args) {
       //非静态可以直接调用静态方法,静态方法不管你用不用都存在
        //非静态方法只有你调用的时候才存在
        go();//可以直接调用方法
    }
}
 
public  class Student {
    {
        //代码块 (匿名代码块),每次运行方法都要执行
        System.out.println("匿名代码块");
    }

    static {
        //静态代码块,最快,只执行一次
        System.out.println("静态代码块");
    }
    public void lock(){
        System.out.println("构造方法");
    }

    public static void main(String[] args) {
        Student student = new Student();
        student.lock();
    }
}

import java.lang.Math;//导入包
import static java.lang.Math.random;//静态导入包

public  class Student {

    public static void main(String[] args) {
        System.out.println(Math.random());//可以直接导入包
    }
}

抽象类

//abstract 抽象类:类
//extend类是单继承 接口是可以多继承的
public abstract class Student {

    //约束等人帮我们实现
    //abstract 抽象方法,只有方法名,没有方法的实现
    public abstract void doSomeThing();
}
//特点:不能new出来,只能子类去实现它:约束
//抽象类里可以有普通方法,抽象方法必须是抽象类

接口

//抽象类 extends局限性只能单继承 接口可以继承多个
//实现接口用Impl结尾 用implments 实现
//实现了接口的类就需要重写接口中的方法
public class UserServiceImpl implements UserService,TimeService {

    @Override
    public void add(String name) {

    }

    @Override
    public void delete(String name) {

    }

    @Override
    public void update(String name) {

    }

    @Override
    public void query(String name) {

    }

    @Override
    public void time(double num) {

    }
}
//interface 定义关键词  接口都需要实现类
public interface UserService {
    //接口中的所有定义其实都是抽象的 public abstract

    void add(String name);
    void delete(String name);
    void update(String name);
    void query(String name);
}
public interface TimeService {
    void time(double num);
    
    public static final int age=99;
    // 定义常量接口中定义的属性都是常量,一般不这么用
}

内部类

public class Outer {
    private int id = 10;
    public void out(){
        System.out.println("这是外部类");
    }
    class Inner{
        public void in(){
            System.out.println("这是内部类");
        }
        //内部类可以获得外部类的私有属性,方法
        public void getID(){
            System.out.println(id);
        } //public static void getID(){
            //System.out.println(id);} 静态内部类
    }
    public void method(){
        class Inner{
            public void in(){
                System.out.println("这是局部内部类");
            }
        }
    }


    public static void main(String[] args) {
        Outer outer = new Outer();
        //new一个类
        Inner inner = outer.new Inner();
        //通过new的类引用内部类
        inner.in();
    }
}
//一个java文件只能有一个public 可以有多个class可以直接跑main方法测试
class A {

        }
public class Test {
    public static void main(String[] args) {
        //没有名字的初始化,不用将实例保存倒变量中
        //匿名内部类
        new Apple().eat();

        //可以直接new一个接口
        
    }
}
class Apple{
    public void eat(){
        System.out.println("eat");
    }
}
interface UserService{//接口
    void hello();
}

异常

package Students.Exception;

public class Demo01 {

    public static void main(String[] args) {


        int a = 1;
        int b = 0;

        try {//监控区域
            System.out.println(a/b);
        }catch(ArithmeticException i){//捕获异常
            System.out.println("这是一个异常,变量不能为零");

        }finally{//处理善后工作,可以不要
            System.out.println("finally");
        }//占用资源要关闭


        try{
            new Demo01().a();
        }catch (Throwable e){//(想要捕获的异常,后接异常定义名)可以写多个catch
            System.out.println("错误");
        }

        //假设需要捕获多个异常,从小到大
    }
    public void a(){
        b();
    }
    public void b(){
        a();
    }
}
package Students.Exception;

public class Demo02 {
    public static void main(String[] args) {
        int a = 4;
        int b = 0;

        try {//Ctrl Alt + T 自动包裹代码
            System.out.println(a/b);
        } catch (Exception e) {
            e.printStackTrace();//打印错误的栈信息
        }

        try {
            if (b==0){//主动抛出异常 throw throws
                throw new ArithmeticException();//主动new异常
            }
        } catch (ArithmeticException e) {
              
        }
    }
}
package Students.Exception;

public class Demo02 {
    public static void main(String[] args) {

    }
    public void test(int a , int b) throws ArrayStoreException{//方法上抛出异常是throws
        if (b==0){
            throw new ArrayStoreException();//主动抛出异常一般在方法中使用
        }
    }
}

javaSE总结

标签:最快   否则   err   aot   pack   query   load   row   数组   

原文地址:https://www.cnblogs.com/kirret/p/14418305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!