找回密码
 立即注册
相关推荐换一批
  1. 冀教版小学二年级下册语文第五单元综合能力测试卷
  2. GB/T 17603-1998 光解性塑料户外暴露试验方法
  3. GB/T 17548-1998 信息技术 POSIX 依从性的测试方法
  4. GB/T 17518-1998 化工产品中硅含量测定的通用方法还原硅钼酸盐分光光度法
  5. GB/T 17431.2-1998 轻集料及其试验方法 第2部分:轻集料试验方法
  6. GB 13917.8-1992 农药登记卫生用杀虫剂室内药效试验方法 模拟现场药效测定方法
  7. GB 13917.2-1992 农药登记卫生用杀虫剂室内药效试验方法 气雾剂的室内药效测定方法
  8. GB 13917.1-1992 农药登记卫生用杀虫剂室内药效试验方法 喷射剂的室内药效测定方法
  9. GB/T 17280-1998 原油蒸馏标准试验方法
  10. GB/T 17042-1997 航空轮胎胎圈耐高温试验方法
  11. GB/T 16886.10-2000 医疗器械生物学评价 第10部分:刺激与致敏试验
  12. GB/T 16860-1997 感官分析方法 质地剖面检验
  13. GB/T 16850.7-2001 光纤放大器试验方法基本规范 第7部分:外带插入损耗的试验方法
  14. GB/T 16850.5-2001 光纤放大器试验方法基本规范 第5部分:反射参数的实验方法
  15. GB/T 16850.3-1999 光纤放大器试验方法基本规范 第3部分:噪声参数的试验方法
  16. GB/T 16850.2-1999 光纤放大器试验方法基本规范 第2部分:功率参数的试验方法
  17. GB/T 16850.1-1997 光纤放大器试验方法基本规范 第1部分:增益参数的试验方法
  18. GB/T 16822-1997 介电晶体介电性能的试验方法
  19. GB/T 16701.1-1996 热电偶材料试验方法 第1部分:贵金属热电偶丝热电动势测量方法
  20. GB/T 16659-1996 煤中汞的测定方法
  21. GB/T 16658-1996 煤中铬、镉、铅的测定方法
  22. GB/T 16613-1996 试验用聚氯乙烯(PVC)糊的制备 分散器法
  23. GB/T 16600-1996 钨的发射光谱分析方法
  24. GB/T 16599-1996 钼的发射光谱分析方法
上季内容回顾:
1、super与this关键词
2、方法的重载与覆写
本季首要知识点:
1、final关键词
2、简单理解一下笼统类与接口(是JAVA中最主要的部分)
final关键词
终结器——final
1、被final符号的类不能被承继
finalclassA
{
};
classBextendsA
{
};
验证一下:
2、被final符号的方法不能被子类覆写
finalclassA
{
publicfinalvoidprint(){}
};
classBextendsA
{
publicvoidprint(){}
};
3、被final符号的变量就变成常量,假如变成常量,则以后不能修改
classA
{
finalStringNAME=Hello;
publicfinalvoidprint()
{
NAME=World;
}
};
之前在声明变量的时候是第一个单词的首字母小写,以后每个单词的首字母大写。假如使用final声明常量,则一切单词的字母都要大写。
重点:大局常量:
·static:是一切目标共享的
·final:是一个常量
·public:表明可以让外部看见
publicstaticfinalStringFLAG=redking.blog.51cto;大局常量
笼统类
笼统类:包括一个笼统方法的类就称为笼统类。
笼统方法:只声明而未实现的方法称为笼统方法。
方法没有方法体(方法体:“{}”),则称为是一个笼统方法。
除了笼统方法之外别的的定义好像一般类相同。
笼统类=一般类的功能+笼统方法
abstractclassA
{
publicstaticfinalStringFLAG=redking.blog.51cto;
publicvoidprint()
{
//有方法体,所以是一个一般方法
System.out.println(HelloWorld~~~);
}
//此处定义了一个笼统方法
publicabstractvoidfun();
};
publicclassDemo04
{
publicstaticvoidmain(Stringargs)
{
Aa=newA();
}
};
假如要使用一个笼统类,不能直接实例化,笼统类是有必要有子类的。
笼统类有必要被承继,被承继的子类假如不是一个笼统类的话,则肯定要覆写全面的笼统方法。
abstractclassA
{
publicstaticfinalStringFLAG=redking.blog.51cto;
publicvoidprint()
{
//有方法体,所以是一个一般方法
System.out.println(HelloWorld~~~);
}
//此处定义了一个笼统方法
publicabstractvoidfun();
};
//子类中覆写了笼统类中的全面笼统方法
classBextendsA
{
publicvoidfun()
{
//super.FLAG也可以写成FLAG,由于FLAG现已是大局常量了哈~~~
System.out.println(FLAG=+super.FLAG);
}
};
publicclassDemo04
{
publicstaticvoidmain(Stringargs)
{
Bb=newB();
b.fun();
b.print();
}
};
验证效果,证明笼统类有必要这样写哈~~~
笼统类的定义
笼统类的使用规则
笼统类的考虑
abstractclassPerson
{
//Person类应该有名字和年纪
privateStringname;
privateintage;
publicPerson(Stringname,intage)
{
this.name=name;
this.age=age;
}
publicvoidsetName(Stringname)
{
this.name=name;
}
publicvoidsetAge(intage)
{
this.age=age;
}
publicStringgetName()
{
returnthis.name;
}
publicintgetAge()
{
returnthis.age;
}
//定义一个输出方法,可是此方法为笼统方法
publicabstractStringgetInfo();
};
我们测试一下,发现编译正常,说明笼统类可以有结构方法哈~
我们持续哈~
abstractclassPerson
{
//Person类应该有名字和年纪
privateStringname;
privateintage;
publicPerson(){}
//假如现已不是无参的,则有必要在子类中清晰调用无参结构
publicPerson(Stringname,intage)
{
this.name=name;
this.age=age;
}
publicvoidsetName(Stringname)
{
this.name=name;
}
publicvoidsetAge(intage)
{
this.age=age;
}
publicStringgetName()
{
returnthis.name;
}
publicintgetAge()
{
returnthis.age;
}
//定义一个输出方法,可是此方法为笼统方法
publicabstractStringgetInfo();
};
classStudentextendsPerson
{
publicStudent(Stringname,intage)
{
//调用Person类中有两个参数的结构方法
super(name,age);
}
//覆写父类的笼统方法
publicStringgetInfo()
{
return名字:+super.getName()+,年纪:+super.getAge();
}
};
publicclassDemo05
{
publicstaticvoidmain(Stringargs)
{
Students=newStudent(王乾,27);
System.out.println(s.getInfo());
}
}
笼统类中许可有结构方法,可是此结构方法并不是直接实例化笼统类自己的目标使的,假如在笼统类中没有清晰的无参结构方法,即:存在有参结构,则有必要在子类清晰的使用super指明要调用父类中的那个结构方法。
注意:
假如一个笼统类中没有任何一个笼统方法,则也是不能直接实例化的。
abstractclassA
{
publicvoidprint(){}
};
publicclassDemo06
{
publicstaticvoidmain(Stringargs)
{
newA();
}
};
final可以声明一个类,可是此类是绝对不能有子类的。
而笼统类又有必要被子类承继。==gt;对立的
finalabstractclassA
{

(A recap of last season's content:
1. super and this keywords
2. Method overloading and overriding
Top knowledge points this season:
1. final keywords
2. Simple understanding of general classes and interfaces (the most important part of JAVA)
final keyword
finalizer - final
1. A class marked as final cannot be inherited
finalclassA
{
};
classBextendsA
{
};
Verify it:
2. The method marked as final cannot be overridden by subclasses
finalclassA
{
publicfinalvoidprint(){}
};
classBextendsA
{
publicvoidprint(){}
};
3. The variable symbolized by final becomes a constant. If it becomes a constant, it cannot be modified later
classA
{
finalStringNAME=Hello;
publicfinalvoidprint()
{
NAME=World;
}
};
When declaring variables before, the first letter of the first word is lowercase, and the first letter of each word is uppercase. If you use final to declare constants, all words must be capitalized.
Focus: Big Picture Constants:
static: shared by all targets
final: is a constant
public: indicates that it can be seen by the outside world
publicstaticfinalStringFLAG=redking.blog.51cto;Overall constant
general class
Generic class: A class that includes a generic method is called a generic class.
General method: A method that is only declared but not implemented is called a general method.
A method without a method body (method body: "{}") is called a general method.
Except for the general method, the other definitions are the same as the general class.
General class = function of general class   general method
abstractclassA
{
publicstaticfinalStringFLAG=redking.blog.51cto;
publicvoidprint()
{
//There is a method body, so it is a general method
System.out.println(HelloWorld~~~);
}
//A general method is defined here
publicabstractvoidfun();
};
publicclassDemo04
{
publicstaticvoidmain(Stringargs)
{
Aa=newA();
}
};
If you want to use a general class, you can't instantiate it directly, it is necessary for the general class to have subclasses.
The general class must be inherited. If the inherited subclass is not a general class, it must override the comprehensive general method.
abstractclassA
{
publicstaticfinalStringFLAG=redking.blog.51cto;
publicvoidprint()
{
//There is a method body, so it is a general method
System.out.println(HelloWorld~~~);
}
//A general method is defined here
publicabstractvoidfun();
};
//The subclass overrides the comprehensive general method in the general class
classBextendsA
{
publicvoidfun()
{
//super.FLAG can also be written as FLAG, because FLAG is now an overall constant ha~~~
System.out.println(FLAG= super.FLAG);
}
};
publicclassDemo04
{
publicstaticvoidmain(Stringargs)
{
Bb=newB();
b.fun();
b.print();
}
};
Verify the effect and prove that it is necessary to write the general class like this~~~
Generic class definition
General class usage rules
General Class Considerations
abstractclassPerson
{
//Person class should have name and age
privateStringname;
privateintage;
publicPerson(Stringname,intage)
{
this.name=name;
this.age=age;
}
publicvoidsetName(Stringname)
{
this.name=name;
}
publicvoidsetAge(intage)
{
this.age=age;
}
publicStringgetName()
{
returnthis.name;
}
publicintgetAge()
{
returnthis.age;
}
//Define an output method, but this method is a general method
publicabstractStringgetInfo();
};
Let's test it and find that the compilation is normal, indicating that the general class can have structural methods~
We will continue~
abstractclassPerson
{
//Person class should have name and age
privateStringname;
privateintage;
publicPerson(){}
//If it is not already parameterless, it is necessary to explicitly call the parameterless structure in the subclass
publicPerson(Stringname,intage)
{
this.name=name;
this.age=age;
}
publicvoidsetName(Stringname)
{
this.name=name;
}
publicvoidsetAge(intage)
{
this.age=age;
}
publicStringgetName()
{
returnthis.name;
}
publicintgetAge()
{
returnthis.age;
}
//Define an output method, but this method is a general method
publicabstractStringgetInfo();
};
classStudentextendsPerson
{
publicStudent(Stringname,intage)
{
//Call the structure method with two parameters in the Person class
super(name, age);
}
//Override the general method of the parent class
publicStringgetInfo()
{
return name:  super.getName() , age:  super.getAge();
}
};
publicclassDemo05
{
publicstaticvoidmain(Stringargs)
{
Students=newStudent(Wang Qian,27);
System.out.println(s.getInfo());
}
}
The general class is allowed to have structural methods, but this structural method is not used to directly instantiate the general class's own goal. If there is no clear no-parameter structural method in the general class, that is: there is a parameterized structure, it is necessary to The class clearly uses super to indicate which structural method in the parent class to call.
Notice:
If a general class does not have any general method, it cannot be instantiated directly.
abstractclassA
{
publicvoidprint(){}
};
publicclassDemo06
{
publicstaticvoidmain(Stringargs)
{
newA();
}
};
Final can declare a class, but this class must not have subclasses.
The general class must be inherited by subclasses. ==gt;opposite
finalabstractclassA
{)

[下载]08450503362.rar




上一篇:java数据库编程
下一篇:[零基础学JAVA]Java SE面向对象部分-16.面向对象高级(04)