本文へスキップ
製品デスクトップツールTASTECAD図面の確認TASTEFILESファイル管理TASTEFTPファイル転送TASTESSHリモートワークスペースTASTEZIP圧縮と展開TASTEWINMファイル管理開発ツールTASTECODERust 統合開発環境TASTESTUDIO統合開発・テスト環境TASTEETLデータ統合(ETL)サーバーTASTEREMOTEリモートデスクトップサーバーTASTEGEO空間情報サーバーTASTEMAILメールワークスペース投資TASTESTOCK株式自動売買デスクトップアプリはじめるダウンロードドキュメント購入すべての製品
マーケットプレイス
ニュース
技術ニュース今日の開発ニュース開発ドキュメントプログラミング言語RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWebフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngularサーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Expressアプリ・デスクトップ フレームワークTauriFlutterReact NativeElectronアルゴリズムアルゴリズムの基礎主要アルゴリズム発展アルゴリズム実務のアルゴリズム
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケースコミュニティガイド
協業技術移転ウェブサイト構築デスクトップアプリ構築リリース・決済パイプライン販売パートナーお問い合わせ
サービスリモートデスクトップインストールパッケージのカスタマイズ
TASTEDEV
製品

デスクトップツール

TASTECAD複雑な図面を、軽やかにひらくTASTEFILES必要なファイルだけを、最速でTASTEFTPファイルが行き交う、いちばん端正な道TASTESSHサーバーとあなたを、より確かにつなぐTASTEZIPより速くまとめ、より安全にひらくTASTEWINM2つの画面で整理する、キーボード中心のファイルマネージャー

開発ツール

TASTECODERust アプリの編集・ビルド・デバッグ・テストまでひとつのウィンドウでTASTESTUDIO編集からリモートテスト、承認した AI 修正までTASTEETL値を見ながら、データを運ぶ

サーバー

TASTEREMOTE自社サーバーで運用するリモートデスクトップTASTEGEOGeoServer 互換の空間情報サーバーを Rust で作り直しますTASTEMAILメールの主導権を、もう一度自分の手に

投資

TASTESTOCKいつ・何を。自分で決めたルールどおりに動く株式自動売買

はじめる

ダウンロード全製品の最新版ドキュメント各製品の使い方購入サブスクリプション・永久ライセンスすべての製品全製品を一覧で
すべての製品
マーケットプレイスニュース
技術

ニュース

今日の開発ニュース言語・フレームワーク・GitHub・AI の公式発表開発ドキュメント言語・フレームワーク・アルゴリズムのガイド

プログラミング言語

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

フレームワーク

Webフロントエンド フレームワークNext.jsReactVue.js · NuxtSvelteKitAngular
サーバー フレームワークSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
アプリ・デスクトップ フレームワークTauriFlutterReact NativeElectron

アルゴリズム

アルゴリズムの基礎計算量解析 · ソート · 探索 · 基本データ構造 · 木構造とヒープ主要アルゴリズムグラフ探索 · 最短経路と最小全域木 · 動的計画法 · 貪欲法 · 分割統治法 · バックトラッキング発展アルゴリズム文字列アルゴリズム · 数学と整数論 · ビット演算 · セグメント木 · Union-Find実務のアルゴリズムコーディング面接対策 · LRUキャッシュ · レート制限 · コンシステントハッシュ法
開発ドキュメントをすべて見る
コミュニティ
プロジェクトビルダーと作品を探す開発ログ決定と試行錯誤プロンプト再利用できる指示AIツールの問題Claude・Codex・Gemini の問題と回避策ショーケース完成した成果コミュニティガイドオープンにつくる方法
協業
技術移転Rust・egui でネイティブアプリを作るウェブサイト構築10言語、アカウント、ドキュメントとダウンロードデスクトップアプリ構築Rust・egui、WebView なしリリース・決済パイプライン署名・MSI・deb・rpm・AppImage・ハッシュ販売パートナー紹介して決済額の30%お問い合わせ構築・提携・投資のご相談
サービス
リモートデスクトップブラウザから自分のパソコンへインストールパッケージのカスタマイズ必要な機能だけ、設定は事前に
購入
JA
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
ログイン
ログイン
TASTEDEV

小さなツールから、より良い開発へ。

support@tastedev.netTASTEDEVを支援
製品製品ラインナップ購入ドキュメントダウンロードマーケットプレイスサポート
コミュニティプロジェクト開発ログプロンプトAIツールの問題ショーケース
ポリシー会社概要プライバシーポリシー利用規約サブスクリプション規約返金ポリシーコミュニティガイドライン
アカウントログイン新規登録
訪問者
今日
昨日
累計閲覧
商号
GXSOFT
代表者
CHOI YOUNG GU
事業者登録番号
853-44-00368
所在地
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
電話
+82-10-4404-1523
メール
whitecalvin@tastedev.net
個人情報保護責任者
CHOI YOUNG GU

© 2026 TASTEDEV製品情報は検証済みの開発ソースに基づいています。リリース・改善中

Java ドキュメント
Java
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
ディスカッション

Java ガイド · 2/6

Syntax Basics

この章は現在、英語でのみ提供しています。

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.

この章について質問がありますか?
前の章Getting Started次の章Types 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件

人気のコメント順新しい順

ログイン · ログインするとコメントできます。