每天JAVA多一點

來源:互聯網
上載者:User

其實,以前就知道一些JAVA的事,最近打算抽時間再重看看。

1,源碼,類名最好保持一致,最好不要不加訪問限定符。

2,System.out.print() 末尾不加斷行符號;System.out.println() 末尾加斷行符號;

3,^位異或;~位非;!布爾非

4,運行時,可以多進入點運行可以每個類都設定main函數,而且彼此調用,因為是解譯器,所以不必連結,所以解釋只要聲明一個確定的無二義性的main函數入口,其他一切的隨著程式的運轉自動調用,即使調用其他類的main函數也無所謂

實驗1:

class first_program
{
public static void main(String args[])
{
   second_program secProgram = new second_program();
   secProgram.paint();
}
public void paint()
{
   System.out.println("The First FIghting~~~!!!");
}
}

class second_program
{
public void paint()
{
   System.out.println("The Second FIghting~~~!!!");
}
public static void main(String args[])
{
   first_program firProgram = new first_program();
   firProgram.paint();
}
}

實驗2:

class first_program
{
public static void main(String args[])
{
   second_program secProgram = new second_program();
   secProgram.paint();
   second_program.main();
}
public void paint()
{
   System.out.println("The First FIghting~~~!!!");
}

}

class second_program
{
public void paint()
{
   System.out.println("The Second FIghting~~~!!!");
}
public static void main()
{
   first_program firProgram = new first_program();
   firProgram.paint();
}
}

分別試一試,現象很有趣

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.