Java is a versatile, object-oriented programming language first released by Sun Microsystems in 1995. It's designed to be platform-independent, following the principle of "Write Once, Run Anywhere" (WORA). This means that Java code can run on any device or operating system that has a Java Virtual Machine (JVM) installed, without needing to be recompiled.
History
In June 1991, a small team of engineers at Sun Microsystems led by James Gosling (along with Mike Sheridan and Patrick Naughton) started a project called Green. This is to develop a programming language for small electronic devices such as television, setup-box, etc.
In 1993, the HTTP protocol and Mosaic browser arrived which made them to develop the language for the internet.
In 1995, they developed a browser named Webrunner which is capable of showing HTML content mixed with applets. Sun Microsystems officially announced Java at the SunWorld conference and Netscape agreed to include Java support in their popular Netscape Navigator browser.
In 2009, Sun Microsystems was bought by Oracle. It was initially named 'OAK' after an oak tree that stood outside his office. Then, it was renamed to 'JAVA' as the 'OAK' trademark was already used by Oak Technology.
Java is widely used for developing enterprise-level applications, Android mobile apps, web applications, and more.
To start programming in Java, you need to set up your development environment. Here's a step-by-step guide:
Download and install the Java Development Kit (JDK):
Set up environment variables:
Install an Integrated Development Environment (IDE):
Verify your installation:
Let's create a simple "Hello, World!" program to ensure your Java environment is set up correctly and to introduce you to basic Java syntax.
Open your text editor or IDE.
Create a new file and name it HelloWorld.java.
Enter the following code:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } }
Save the file.
Open a command prompt or terminal, navigate to the directory containing your HelloWorld.java file.
Compile the program by typing:
javac HelloWorld.java
This will create a HelloWorld.class file.
java HelloWorld
You should see the output: Hello, World!
Congratulations! You've just written and run your first Java program.
Let's break down the code:
public class HelloWorld: This declares a public class named HelloWorld. In Java, the class name must match the filename.
public static void main(String[] args): This is the main method, the entry point of any Java program.
System.out.println("Hello, World!");:此行列印文字「Hello, World!」到控制台。
隨著我們繼續學習 Java,在下一篇文章中,我們將討論 Java 語法基礎知識。我們將探索更複雜的概念,如變數、資料類型、控制結構、物件導向程式設計等等。
我很想聽聽您使用 Java 的經驗!
您最想了解 Java 的哪個方面,為什麼?
如果您發現本文有幫助,請考慮關注以獲取更多 Java 內容。非常感謝您的讚和評論 - 它們幫助我了解您最感興趣的主題,使我能夠根據您的需求自訂未來的內容。
您在設定 Java 環境時遇到任何問題嗎?在下面的評論中分享您的經驗,讓我們一起解決問題!
請繼續關注我們的下一篇有關 Java 語法基礎知識的文章。快樂編碼!
以上是Java 簡介:針對初學者的詳細內容。更多資訊請關注PHP中文網其他相關文章!