0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Java 学習メモ(まとめ①) 基本的な書き方エラーメッセージ(随時更新)

0
Last updated at Posted at 2026-05-31

クラスの宣言

public class Main {
    // ここに内容を書く
}
  • プログラムは、必ずクラスの中に書く
  • ファイル名はクラス名と一致させる
  • 上記の場合はファイル名は Main.java

mainメソッド

public static void main(String[] args){
    //ここに処理を書く
}
  • Java プログラムの 実行開始地点(エントリーポイント)

画面への出力

System.out.print("Hello ");
System.out.print("World");

↓

結果
Hello World
System.out.println("Hello ");
System.out.println("World");

↓

結果
Hello
World
  • 改行したい場合はprintlnを使う

セミコロン

ステートメントの末尾には必ず;を付ける
※付け忘れ⇒コンパイルエラー

波括弧

処理のまとまりに{}を付ける
※付け忘れ⇒コンパイルエラー

インデント

インデントとして半角スペース 4つ開ける
※可読性の向上につながる

コメントの付け方

// コメント
/*
コメント1行目
コメント2行目
*/

コンパイルエラー

エラーメッセージ 主な原因 確認ポイント
';' expected セミコロン(;)の付け忘れ エラーが表示された行の前後で、文の末尾に ; があるか確認する
reached end of file while parsing 波括弧(})の閉じ忘れ { と } の数が合っているか確認する
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?