其實,以前就知道一些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();
}
}
分別試一試,現象很有趣