在Java语言中规定使用this关键字来代表本类对象的引用,this关键字被隐式地用于引用对象的成员变量和方法. this关键字引用的就是本类的一个对象,在局部变量或方法参数覆盖了成员变量时,就要添加this关键字明确引用的是类成员还是局部变量或方法参数. package mingri.chapter_6; public class BookTest { public String name; public void setName(String name) { this.name = name…
1.final关键字和.net中的const关键字一样,是常量的修饰符,但是final还可以修饰类.方法.写法规范:常量所有字母都大写,多个单词中间用 "_"连接. 2.遍历集合ArrayList<Integer> list = new ArrayList<Integer>();list.add(1);list.add(3);list.add(5);list.add(7);// 遍历List方法1,使用普通for循环:for (int i = 0; i <…
使用static关键字修饰的变量.常量和方法分别被称作静态变量.静态常量和静态方法,也被称作类的静态成员 静态变量 使用static修饰过的类变量称为静态变量 该变量需要使用类名.变量名进行调用,不能使用对象名/this进行调用 在类方法中不能定义与静态变量同名的局部变量 package mingri.chapter_6; public class Pool { public static int water = 0; // 定义一个静态变量 public void outlet() { //…
之前一直认为,super指向的是父类对象.到今天,仔细查询了资料,自己做了实验,确认这个结论是不对的.我们分一下几个点讨论下: super的作用: 第一种:用来访问父类被隐藏的成员变量 第二种:用来调用父类中被重载的方法 第三种:用来调用父类的构造函数 super真的指向父类对象吗? 代码直接分析: public class Super { public void test() { System.out.println("super test 执行了"); } } public c…
这里面主要介绍一下关于String类中的split方法的使用以及原理. split函数的说明 split函数java docs的说明: When there is a positive-width match at the beginning of this string then an empty leading substring is included at the beginning of the resulting array.A zero-width match at the beg…