Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneTASTEWINMGestione fileStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailInvestimentiTASTESTOCKApp desktop di trading automatico azionarioIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuroTASTEWINMUn file manager a due pannelli pensato per la tastiera

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Investimenti

TASTESTOCKTrading automatico azionario secondo le regole che decidi tu: quando e che cosa

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeChi siamoInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
Ieri
Visualizzazioni totali
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di Java
Java
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
Discussioni

Guida a Java · 2/6

Syntax Basics

Per ora questo capitolo è disponibile solo in inglese.

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.

Domande su questo capitolo?
Capitolo precedenteGetting StartedCapitolo successivoTypes 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 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.