java複習進程

來源:互聯網
上載者:User
開始:

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過的類的對象,會出現null 指標異常.

抽象類別:
凡有抽象方法的類就是一個抽象類別,用abstract 修飾.
抽象方法沒有方法體,預設為public修飾符.
不能對抽象類別進行new操作,有子類抽象類別才有意義
abstract和final不能修飾同一個類,final類代表最終類,不能有子類.
Start();  //用來調用run()方法
Sleep(long t);  //t為睡眠的毫秒數

多線程
java.lang.Thread包
在類中擴充(Extends) Thread類, 當程式需要在繼承Thread類而又要繼承另外的一個類時,可以implements Runnable介面並實現run()方法

進程中所有線程共用同一記憶體空間.
只有一條線程的進程稱為單線程
有不止一個線程的進程稱為多線程
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.