Heim > Java > javaLernprogramm > Hauptteil

Einführung in Java: für Anfänger

Mary-Kate Olsen
Freigeben: 2024-10-05 06:13:02
Original
259 Leute haben es durchsucht

Introduction to Java

What is Java?

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.

Introduction to Java: for Beginners

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.

Introduction to Java: for Beginners

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.

Key features of Java include:

  1. Object-oriented: Java is built around the concept of "objects" that contain data and code.
  2. Platform independence: Java code can run on any platform with a JVM.
  3. Security: Java has built-in security features and a robust security framework.
  4. Multi-threaded: Java supports concurrent programming, allowing multiple threads to run simultaneously.
  5. Large standard library: Java comes with a comprehensive set of standard libraries and APIs.

Java is widely used for developing enterprise-level applications, Android mobile apps, web applications, and more.

Setting up Java Environment

To start programming in Java, you need to set up your development environment. Here's a step-by-step guide:

  1. Download and install the Java Development Kit (JDK):

    • Visit the official [Oracle website](https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html or adopt the OpenJDK website.
    • Download the appropriate JDK version for your operating system.
    • Follow the installation instructions provided.
  2. Set up environment variables:

    • Add the Java bin directory to your system's PATH variable.
    • Create a JAVA_HOME environment variable pointing to your JDK installation directory.
  3. Install an Integrated Development Environment (IDE):

    • While not strictly necessary, an IDE can greatly enhance your Java development experience.
    • Popular choices include IntelliJ IDEA, Eclipse, VScode, and NetBeans.
    • Download and install your preferred IDE.
  4. Verify your installation:

    • Open a command prompt or terminal.
    • Type java -version and press Enter. You should see information about your installed Java version.
    • Type javac -version to check if the Java compiler is correctly installed.

Your First Java Program

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.

  1. Open your text editor or IDE.

  2. Create a new file and name it HelloWorld.java.

  3. Enter the following code:


public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}


Nach dem Login kopieren
  1. Save the file.

  2. Open a command prompt or terminal, navigate to the directory containing your HelloWorld.java file.

  3. Compile the program by typing:


javac HelloWorld.java


Nach dem Login kopieren

This will create a HelloWorld.class file.

  1. Run the program by typing:

java HelloWorld


Nach dem Login kopieren

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!");: Diese Zeile druckt den Text „Hello, World!“ zur Konsole.

Während wir weiterhin Java lernen, werden wir im nächsten Artikel die Grundlagen der Java-Syntax besprechen. Wir werden komplexere Konzepte wie Variablen, Datentypen, Kontrollstrukturen, objektorientierte Programmierung und vieles mehr untersuchen.

Ich würde gerne von Ihren Erfahrungen mit Java hören!
Auf welchen Aspekt von Java freuen Sie sich am meisten und warum?

Wenn Sie diesen Artikel hilfreich fanden, folgen Sie ihm bitte für weitere Java-Inhalte. Ihre „Gefällt mir“-Angaben und Kommentare freuen uns sehr – sie helfen mir zu verstehen, welche Themen Sie am meisten interessieren, und ermöglichen es mir, zukünftige Inhalte an Ihre Bedürfnisse anzupassen.

Sind beim Einrichten Ihrer Java-Umgebung Probleme aufgetreten? Teilen Sie Ihre Erfahrungen in den Kommentaren unten und lassen Sie uns gemeinsam Probleme lösen!
Seien Sie gespannt auf unseren nächsten Artikel über die Grundlagen der Java-Syntax. Viel Spaß beim Codieren!

Das obige ist der detaillierte Inhalt vonEinführung in Java: für Anfänger. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Quelle:dev.to
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Neueste Artikel des Autors
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!