Zum Hauptinhalt springen
ProdukteDesktop-WerkzeugeTASTECADZeichnungsprüfungTASTEFILESDateiverwaltungTASTEFTPDateiübertragungTASTESSHRemote-ArbeitsbereichTASTEZIPKomprimieren und EntpackenTASTEWINMDateiverwaltungEntwicklerwerkzeugeTASTECODEIntegrierte Entwicklungsumgebung für RustTASTESTUDIOIntegrierte Entwicklungs- und TestumgebungTASTEETLDatenintegration (ETL)ServerTASTEREMOTERemote-Desktop-ServerTASTEGEOGeodatenserverTASTEMAILE-Mail-ArbeitsbereichInvestierenTASTESTOCKDesktop-App für automatischen AktienhandelErste SchritteDownloadsDokumentationKaufenAlle Produkte
Marktplatz
Neuigkeiten
TechnikNeuigkeitenEntwickler-News von heuteEntwicklerdokuProgrammiersprachenRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp- & Desktop-FrameworksTauriFlutterReact NativeElectronAlgorithmenAlgorithmus-GrundlagenKernalgorithmenFortgeschrittene AlgorithmenAlgorithmen für die Praxis
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcaseCommunity-Leitfaden
ZusammenarbeitWissenstransferWebsite-AufbauDesktop-App-AufbauRelease- und ZahlungspipelineVertriebspartnerKontakt
DiensteRemote-DesktopIndividuelle Installationspakete
TASTEDEV
Produkte

Desktop-Werkzeuge

TASTECADKomplexe Zeichnungen, mühelos geöffnetTASTEFILESNur die Dateien, die zählen – in BestzeitTASTEFTPDer aufgeräumteste Weg für Ihre DateienTASTESSHDie stärkere Verbindung zu Ihren ServernTASTEZIPSchneller packen, sicherer entpackenTASTEWINMEin tastaturorientierter Dateimanager mit zwei Fenstern

Entwicklerwerkzeuge

TASTECODERust-Apps bearbeiten, bauen, debuggen und testen – alles in einem FensterTASTESTUDIOVom Bearbeiten bis zu Remote-Tests und freigegebenen KI-KorrekturenTASTEETLDaten bewegen, die Werte im Blick

Server

TASTEREMOTEEin Remote-Desktop auf Ihrem eigenen ServerTASTEGEOEin GeoServer-kompatibler Geodatenserver, neu aufgebaut in RustTASTEMAILIhre E-Mail wieder in Ihrer Hand

Investieren

TASTESTOCKAutomatischer Aktienhandel nach Ihren Regeln: wann und was

Erste Schritte

DownloadsNeueste Versionen aller ProdukteDokuSo nutzen Sie jedes ProduktKaufenAbos und DauerlizenzenAlle ProdukteAlle Produkte im Überblick
Alle Produkte
MarktplatzNeuigkeiten
Technik

Neuigkeiten

Entwickler-News von heuteOffizielle Meldungen zu Sprachen, Frameworks, GitHub und KIEntwicklerdokuAnleitungen zu Sprachen, Frameworks und Algorithmen

Programmiersprachen

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web-Frontend-FrameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server-FrameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App- & Desktop-FrameworksTauriFlutterReact NativeElectron

Algorithmen

Algorithmus-GrundlagenKomplexitätsanalyse · Sortieren · Suchen · Grundlegende Datenstrukturen · Bäume und HeapsKernalgorithmenGraphtraversierung · Kürzeste Wege und minimale Spannbäume · Dynamische Programmierung · Greedy-Algorithmen · Teile und herrsche · BacktrackingFortgeschrittene AlgorithmenZeichenkettenalgorithmen · Mathematik und Zahlentheorie · Bitmanipulation · Segmentbäume · Union-FindAlgorithmen für die PraxisStrategie für Coding-Interviews · LRU-Cache · Rate Limiting · Konsistentes Hashing
Alle Entwicklungsdokumente
Community
ProjekteEntwickler und Projekte entdeckenEntwicklungslogsEntscheidungen und ErkenntnissePromptsWiederverwendbare AnweisungenProbleme mit KI-ToolsProbleme und Workarounds für Claude, Codex, GeminiShowcaseFertige ErgebnisseCommunity-LeitfadenWie wir offen entwickeln
Zusammenarbeit
WissenstransferNative Apps mit Rust und eguiWebsite-Aufbau10 Sprachen, Konten, Dokumentation und DownloadsDesktop-App-AufbauRust und egui, ohne WebViewRelease- und ZahlungspipelineSignatur, MSI, deb, rpm, AppImage, PrüfsummenVertriebspartnerEmpfehlen und 30 % erhaltenKontaktEntwicklung, Partnerschaft, Investition
Dienste
Remote-DesktopIhren Computer im Browser erreichenIndividuelle InstallationspaketeNur nötige Funktionen, Einstellungen vorab
Kaufen
DE
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Anmelden
Anmelden
TASTEDEV

Von kleinen Werkzeugen zu besserer Entwicklung.

support@tastedev.netTASTEDEV unterstützen
ProdukteProduktübersichtKaufenDokuDownloadsMarktplatzSupport
CommunityProjekteEntwicklungslogsPromptsProbleme mit KI-ToolsShowcase
RichtlinienÜber unsDatenschutzerklärungNutzungsbedingungenAbo-BedingungenRückerstattungCommunity-Richtlinien
KontoAnmeldenRegistrieren
Besucher
Heute
Gestern
Aufrufe gesamt
Firma
GXSOFT
Vertretungsberechtigt
CHOI YOUNG GU
Handelsregisternummer
853-44-00368
Anschrift
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefon
+82-10-4404-1523
E-Mail
whitecalvin@tastedev.net
Datenschutzbeauftragter
CHOI YOUNG GU

© 2026 TASTEDEVProduktinformationen basieren auf verifizierten Entwicklungsquellen.Veröffentlicht · wird verbessert

Java-Dokumentation
Java
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
Diskussionen

Java-Anleitung · 2/6

Syntax Basics

Dieses Kapitel ist vorerst nur auf Englisch verfügbar.

Java is statically typed, and all code lives inside classes. Statements end with semicolons and blocks are wrapped in braces. This chapter covers classes and the main method, variables and var, methods, branching and loops, switch expressions, and working with strings.

Classes and main

A class bundles state (fields) with behavior (methods). A runnable program needs one class with a main method. The static keyword means the method belongs to the class itself, so it can be called without creating an object first.

package com.example.basics;

public class Greeter {
    private final String greeting; // field

    public Greeter(String greeting) { // constructor
        this.greeting = greeting;
    }

    public String greet(String name) { // instance method
        return greeting + ", " + name;
    }

    public static void main(String[] args) {
        Greeter greeter = new Greeter("Hello");
        System.out.println(greeter.greet("Java"));
    }
}

There are four access levels: public (visible everywhere), protected (same package plus subclasses), package-private (no modifier at all), and private (only inside the class). The usual habit is to keep fields private and expose only the methods callers actually need.

Variables and var

You declare a variable with a type and a name. For local variables you can write var and let the compiler infer the type from the initializer. This is not dynamic typing: the inferred type is fixed for the life of the variable. Mark a variable final to prevent reassignment.

int count = 10;
double ratio = 0.75;
boolean done = false;
String title = "Java";

var names = new java.util.ArrayList<String>(); // inferred as ArrayList<String>
names.add("Duke");

final int max = 100;
// max = 200; // compile error: cannot assign a value to final variable

var only works for local variables, not for fields or method parameters. It shines when the type is long and already obvious from the right-hand side.

Methods

A method declaration lists a return type, a name, and parameters; use void when nothing is returned. Overloading lets you define several methods with the same name as long as their parameter lists differ. Java always passes arguments by value; for objects, the value being copied is the reference.

public class MathUtil {
    static int add(int a, int b) {
        return a + b;
    }

    static double add(double a, double b) { // overload
        return a + b;
    }

    static int sum(int... values) { // varargs
        int total = 0;
        for (int v : values) total += v;
        return total;
    }
}

Branching and loops

The usual suspects are all here: /, the classic , the enhanced for-each loop, , and . Use to leave a loop early and to skip to the next iteration.

Fragen zu diesem Kapitel?
Vorheriges KapitelGetting StartedNächstes KapitelTypes and Data
if
else
for
while
do-while
break
continue
int score = 82;
if (score >= 90) {
    System.out.println("A");
} else if (score >= 80) {
    System.out.println("B");
} else {
    System.out.println("C");
}

for (int i = 0; i < 3; i++) {
    System.out.println("i = " + i);
}

for (String lang : java.util.List.of("Java", "Kotlin", "Scala")) {
    if (lang.equals("Kotlin")) continue;
    System.out.println(lang);
}

int n = 3;
while (n > 0) {
    n--;
}

Switch expressions

The old switch statement falls through to the next case whenever you forget a break. The arrow form (->) never falls through and produces a value, so you can assign or return it directly. When a case needs several statements, use a block and hand back the result with yield.

enum Day { MON, TUE, WED, THU, FRI, SAT, SUN }

static String kind(Day day) {
    return switch (day) {
        case SAT, SUN -> "weekend";
        case MON, TUE, WED, THU, FRI -> "weekday";
    };
}

static int length(Object value) {
    return switch (value) {
        case String s -> s.length();
        case java.util.List<?> list -> list.size();
        case null -> 0;
        default -> {
            String text = value.toString();
            yield text.length();
        }
    };
}

When every enum constant is covered, no default branch is needed. The second example uses type patterns: each case checks the runtime type and binds the value to a new variable in one step.

Strings

String objects are immutable; every method that seems to modify a string actually returns a new one. Compare contents with equals, never ==, because == only checks whether two references point at the same object.

String s = "  Hello, Java  ";
String trimmed = s.strip(); // "Hello, Java"
boolean same = trimmed.equals("Hello, Java"); // true
String upper = trimmed.toUpperCase();
String[] parts = trimmed.split(", "); // ["Hello", "Java"]
String message = "%s has %d chars".formatted(trimmed, trimmed.length());

String json = """
    {
      "name": "Duke",
      "lang": "Java"
    }
    """; // text block

StringBuilder sb = new StringBuilder();
for (int i = 0; i < 3; i++) sb.append(i).append(',');
System.out.println(sb); // 0,1,2,

When you build up a string piece by piece inside a loop, a StringBuilder avoids creating a pile of throwaway objects. For multi-line content, text blocks delimited by triple quotes keep the text readable without escape sequences.

Summary

  • All code lives in classes, and execution begins at main.
  • Local variables can use var for inference, but their types remain static.
  • Arrow-style switch expressions return a value, never fall through, and support type patterns.
  • Strings are immutable: compare them with equals and build large ones with StringBuilder.

0 Kommentare

Top-KommentareNeueste zuerst

Anmelden · Melde dich an, um einen Kommentar zu schreiben.