java复习进程

开始:

javac *.java编译
java   *(不要文件扩展名)
super.父类的方法和成员变量
子类中调用父类的构造涵数super()必须放在子类构造函数的第一条语句

引用包文件
import  包名
创建包
Backage 包名

声明成员变量时系统会赋一个初始值,但如果在方法中,就一定要在声明同时初始化.

访问修饰符
缺省的访问修饰符(friendly)只能在同一个包中使用,出了包即使是子类也不能使用.'
作用域 当前类 同一package  不同包中的子孙类 不同package中的非子类
public √ √ √ √
protected √ √ √ ×
friendly √ √ × ×
private √ × × ×
不写时默认为friendly                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
java中没有goto语句,但可以有标签;标签只能在循环语句外且和循环语句中间不能有任何语句相隔。
可以用continue和breake到标签。  continue到标签后可以重新进入循环而breake后不能重新进入循环。
标签主要用于退出多层循环。
label1:
for(;;)
{
    continue label1;
    breake label1;
}

用了没有new过的类的对象,会出现空指针异常.

抽象类:
凡有抽象方法的类就是一个抽象类,用abstract 修饰.
抽象方法没有方法体,默认为public修饰符.
不能对抽象类进行new操作,有子类抽象类才有意义
abstract和final不能修饰同一个类,final类代表最终类,不能有子类.
Start();  //用来调用run()方法
Sleep(long t);  //t为睡眠的毫秒数

多线程
java.lang.Thread包
在类中扩展(Extends) Thread类, 当程序需要在继承Thread类而又要继承另外的一个类时,可以implements Runnable接口并实现run()方法


进程中所有线程共享同一内存空间.
只有一条线程的进程称为单线程
有不止一个线程的进程称为多线程
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
posted on 2006-02-09 14:24  泽来  阅读(445)  评论(0编辑  收藏  举报