ホームページ  >  記事  >  Java  >  Java キーワード

Java キーワード

王林
王林オリジナル
2024-08-30 15:21:03243ブラウズ

Java キーワードは、識別子として使用されないプログラミング言語の予約語です。 Java キーワードは、使用している言語によって「予約」されているため、予約語と呼ばれます。これらには、言語のライブラリで定義されている特別な意味があります。

無料ソフトウェア開発コースを始めましょう

Web 開発、プログラミング言語、ソフトウェア テスト、その他

Java プログラミング言語の概念

他のプログラミング言語と同様、Java プログラミング言語のキーワードは特別な意味を持つ予約語です。キーワードは内部プロセス用に予約されており、いくつかの事前定義されたアクションがあります。 Java では、キーワードがそれ以外の方法で使用されると、プログラムまたはコードで「コンパイル時エラー」が発生します。プログラマが使いやすく、キーワードを識別しやすいように、Java ではキーワードが少し「強調表示」されます。

Java のキーワードのリスト

現在 Java で使用されている重要なキーワードを以下にアルファベット順にリストしてみました。同じ例に従うことで、すべてのキーワードの動作を観察することもできます。これらのキーワードを一つずつ見ていきましょう。

1. Abstract: Abstract The keyword is used to declare a class to be used later in the abstract program. Abstract used with a class declaration makes that class an abstract and specifies that the class will be implemented in a subclass at a later stage. Below is an example of the usage of the ‘Abstract’ keyword.Java キーワード2. Assert: The ‘assert’ keyword was added to Java 1.4. This keyword allows a programmer to test his assumptions in the program.Java キーワード3. Boolean: Boolean is a data type that can hold only two values; it’s either a ‘True’ or a ‘False’.Java キーワード4. Break: This keyword helps the programmer want his code to jump out of a loop, for example, a For loop. It’s a control statement that breaks the current flow of the execution on a specific condition provided by the programmer.Java キーワード5. Byte: Byte keyword is one of the data types that are able to store whole numbers. The numbers range from -128 to 127Java キーワード6. Case: Case keyword is used in a switch statement. The ‘case’ keyword creates a block of code and marks it.Java キーワード7. Catch: The ‘catch’ keyword catches the exceptions that were created by the ‘try’ statements. The catch block is used after Try block.Java キーワード8. Char: The ‘char’ is one of the data types that is used to hold one character at a time.Java キーワード9. Class: The class keyword is used to create a class in java. Everything that runs in Java programming resides inside a class.Java キーワード10. Continue: The ‘continue’ keyword is used to skip the current execution and continues to the next step in a loop like a For loop or a While loop.Java キーワード11. Default: The ‘Default’ keyword is used to create a default block of code containing a set of statements executed by default if the required case is not present.Java キーワード12. Do: The ‘do’ keyword is used when creating a ‘do-while’ loop. The ‘do’ block is executed at least once before checking the condition in a while block.Java キーワード13. Double: The ‘double’ keyword is one of the data types used for holding fractional numbers. The fractional numbers range from 1.7e – 308 to 1.7e + 308. While declaring a fraction, the value is ended with a ‘d’.Java キーワード14. Else: The ‘Else’ keyword is used to create a block of code that will be executed if the condition is not ‘True’ in an ‘If’ statement.Java キーワード15. Enum: The ‘enum’ keyword is used to create enumerations, unchangeable data types. The enum keyword defines a fixed set of constants.Java キーワード16. Extends: Extends keyword is used to inherit properties of a superclass’s attributes and methods by a subclass.Java キーワード17. Final: The ‘Final’ keyword is used to set a final value to a variable, making it impossible to overwrite or change altogether. If the value of a final variable is tried to change, it throws an error.Java キーワード When hovered over, it shows the following error.Java キーワード18. Finally: Finally keyword is used along try and catch statements, which has a block that is executed even if the exception is not handled.Java キーワード19. Float: float キーワードは、3.4e-038 から 3.4e+038 までの範囲の小数を保持するデータ型です。小数を宣言する場合、値は「f」で終わる必要があります。Java キーワード20。 For: 「For」キーワードは、ループ (for ループ) を作成するために使用されます。 for ループは、for ループ条件ステートメント内で定義されている、囲まれたコードのセットを何度も実行します。Java キーワード21。 If: 「If」キーワードは、条件が「True」の場合に実行されるコードまたはステートメントのセットまたはブロックを作成するために使用されます。Java キーワード22. Implements: Implement は、インターフェイスを宣言するために予約されているもう 1 つのキーワードです。これはクラスの宣言中に使用され、1 つ以上のインターフェイスを指定します。Java キーワード23. Import: import キーワードは、パッケージ、クラス、またはインターフェイスをインポートするために使用されます。Java キーワード24. Instanceof: 「instanceof」キーワードは、問題のオブジェクトがクラスまたはインターフェイスのインスタンスであるかどうかを確認するために使用されます。Java キーワード25. Int: 「int」キーワードは、整数型を宣言するためのデータ型の 1 つです。Java キーワード26. Interface: Interface キーワードは、抽象メソッドのみを含む特別なタイプのクラスを宣言するために使用されます。インターフェイス メソッドにアクセスするには、「implements」キーワードを使用して別のクラスによる継承の概念を使用するのと同じように、インターフェイスを「実装」する必要があります。

Java キーワード

27. Long: 「long」キーワードも、整数を保持するためのデータ型の 1 つです。範囲は -9223372036854775808 から 9223372036854775808 です。整数値は「L」で終わる必要があります。

Java キーワード

28. New: 「new」キーワードはオブジェクトの作成に使用されます。

Java キーワード

29. Package: 「package」キーワードはパッケージの作成に使用されます。Java キーワード30. Private: 「private」キーワードは、プライベート モード クラスの属性またはメソッドを作成するために使用されます。 「Private」は、宣言されたクラスのみがプライベート プロパティ、属性、メソッドを使用できるようにするアクセス修飾子です。Java キーワード31. Protected: 「Protected」は、同じパッケージまたはサブクラスでのみプロパティまたはメソッドを使用できるようにするアクセス修飾子です。Java キーワード32. Public: 「public」キーワードは、あるクラスがそれ自体内でパブリックに定義されたクラスの属性やメソッドなどを使用できるようにする別のアクセス修飾子です。
以下は、公的に定義されたクラス「test.java」と別のクラス、クラス「Test2.java」です。これにアクセスします。Java キーワードクラス – Test2.javaJava キーワード33. Return: 「return」キーワードはメソッドの実行終了として使用でき、メソッドから値を返すためにも使用されます。Java キーワード34. Short: 「short」キーワードは、-32768 から 32767 までの整数を保持するために使用されるデータ型の一種です。Java キーワード35。 Static: 「static」キーワードは static メソッドを作成するために使用されます。これは、オブジェクトを作成せずにメソッドを呼び出すことができることを意味します。Java キーワード36. Super: 「super」キーワードは、スーパーまたは親クラスまたはオブジェクトを呼び出すために使用されます。Java キーワード37. Switch: 「switch」キーワードは、さまざまなケースにさまざまなシナリオを作成するために使用され、その中から 1 つを選択するために使用されます。 switch ステートメントには値または式が含まれており、存在するすべてのケースと比較され、一致するものが選択されます。Java キーワード38. This: 「this」キーワードは、メソッドまたはコンストラクターの現在のオブジェクトを参照するために使用されます。Java キーワード39. Throw: 「throw」キーワードは、ユーザーの画面に例外メッセージをスローするために使用されます。Java キーワード40. Throws: 「throws」キーワードは、プログラマが例外.41 のタイプ、具体的には を決定してスローしたい場合に使用されます。 Try: 「try」キーワードは「try-catch」ブロックを開始します。 「try」ブロックは例外がテストされる場所です。Java キーワード42. Void: 「void」キーワードは、メソッドで使用される場合、メソッドが戻り値を持たないことを指定します。Java キーワード43. While: 「while」キーワードは、ステートメントに条件を含むループを作成します。ステートメントが true になるまでループが実行されます。Java キーワード

キーワードは、予約されており特別な意味を持つ Java プログラミング言語のトークンです。これらには、その言語で予約された使用と事前定義されたアクションがあります。

以上がJava キーワードの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。