Java内部类(Inner Class)详解
重新来认识一下内部类的区别
1
Static member class(静态成员类)
类声明中包含“static”关键字的内部类。如以下示例代码,
Inner1/Inner2/Inner3/Inner4就是Outer的四个静态成员类。静态成员类的使用方式与一般顶层类的使用方式基本相同。
public
class
Outer{
//
just like static method, static member class has public/private/default access privilege levels
//
access privilege level: public
public
static
class
Inner1 {
public
Inner1() {
//
Static member inner class can access static method of outer class
staticMethod();
//
Compile error: static member inner class can not access instance method of outer class
//
instanceMethod();
}
}
//
access privilege level: default
static
class
Inner2 {
}
//
access privilege level: private
private
static
class
Inner3 {
相关文档:
private void postMethod(String url) throws IOException
{
url = "http://www.newsmth.net/bbslogin2.php";
PostMethod postMethod = new PostMethod(url);
// 填入各个表单域的值
NameValuePair[] data = { new NameValuePair("id ......
一、IO流的三种分类方式
1.按流的方向分为:输入流和输出流
2.按流的数据单位不同分为:字节流和字符流
&n ......
Package 的命名
Package 的名字应该都是由一个小写单词组成。
Class 的命名
Class 的名字必须由大写字母开头而其他字母都小写的单词组成
Class 变量的命名
变量的名字必须用一个小写字母开头。后面的单词用大写字母开头。
Static Final&nbs ......
(1) 用extends关键字创建自己的违例类MyException。为这个类写一个构建器,令其采用String参数,并随同String句柄把它保存到对象内。再写一个main()方法,其中令其在try块内掷出MyException类的一个对象。在catch从句内捕获违例,并打印出字串参数。添加一个finally从句,并打印一条消息,证明自己真正到达那里。
&n ......