Table of Contents
The concept in Java Programming Language
List of Keywords in Java
Home Java javaTutorial Java Keywords

Java Keywords

Aug 30, 2024 pm 03:21 PM
java

A Java keyword is a reserved word in a programming language that is not used as an Identifier. Java Keywords are called reserved words because they are ‘reserved’ by the language you are using. They have a special meaning which is defined in the library of the language.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

The concept in Java Programming Language

Like any other programming language, a Keyword in Java programming language is a reserved word with a special meaning. Keywords are reserved for internal processes and have some predefined actions. In Java, if the keywords are used otherwise, the program or code will encounter a ‘Compile Time Error.’ For ease of use for the programmer and identification of the Keywords, generally, they are a bit ‘highlighted’ in Java.

List of Keywords in Java

We have tried to list the important keywords in use currently in Java below in alphabetical order. You can also observe the working of every keyword by following the given examples for the same. Let’s see these keywords one by one.

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 Keywords2. Assert: The ‘assert’ keyword was added to Java 1.4. This keyword allows a programmer to test his assumptions in the program.Java Keywords3. Boolean: Boolean is a data type that can hold only two values; it’s either a ‘True’ or a ‘False’.Java Keywords4. 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 Keywords5. Byte: Byte keyword is one of the data types that are able to store whole numbers. The numbers range from -128 to 127Java Keywords6. Case: Case keyword is used in a switch statement. The ‘case’ keyword creates a block of code and marks it.Java Keywords7. Catch: The ‘catch’ keyword catches the exceptions that were created by the ‘try’ statements. The catch block is used after Try block.Java Keywords8. Char: The ‘char’ is one of the data types that is used to hold one character at a time.Java Keywords9. Class: The class keyword is used to create a class in java. Everything that runs in Java programming resides inside a class.Java Keywords10. 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 Keywords11. 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 Keywords12. 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 Keywords13. 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 Keywords14. 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 Keywords15. Enum: The ‘enum’ keyword is used to create enumerations, unchangeable data types. The enum keyword defines a fixed set of constants.Java Keywords16. Extends: Extends keyword is used to inherit properties of a superclass’s attributes and methods by a subclass.Java Keywords17. 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 Keywords When hovered over, it shows the following error.Java Keywords18. 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 Keywords19. Float: The float keyword is a data type that holds fractional numbers that range from 3.4e−038 to 3.4e+038. While declaring a fractional number, the value should be ended with an ‘f’.Java Keywords20. For: The ‘For’ keyword is used to create a loop, a for a loop. The for loop executes the enclosed set of code a number of times, which is defined inside the for loop condition statement.Java Keywords21. If: The ‘If’ keyword is used to create a set or block of code or statements that are executed if the condition is ‘True’.Java Keywords22. Implements: Implement is another keyword that is reserved for declaring interfaces. It is used during the declaration of the class and specifies one or more interfaces.Java Keywords23. Import: The import keyword is used for importing packages or a class or classes or maybe an interface as well.Java Keywords24. Instanceof: The ‘instanceof’ keyword is used to check if the object in question is an instance of the class or the interface.Java Keywords25. Int: The ‘int’ keyword is one of the data types for declaring an integer type.Java Keywords26. Interface: The interface keyword is used to declare a special type of class that will only contain abstract methods. For accessing the interface methods, the interface must be “implemented” like we use the inheritance concept by another class by using the ‘implements’ keyword.

Java Keywords

27. Long: The ‘long’ keyword is again one of the data types for holding whole numbers. They range from -9223372036854775808 to 9223372036854775808. The whole number value should end with an ‘L’.

Java Keywords

28. New: The ‘new’ keyword is used to create an object.

Java Keywords

29. Package: The ‘package’ keyword is used to create packages.Java Keywords30. Private: The ‘private’ keyword is used to create attributes or methods for a private mode class. ‘Private’ is an access modifier that allows only the declared class to use private properties or attributes or methods.Java Keywords31. Protected: ‘Protected’ is an access modifier that allows the properties or methods to be used only by the same package or subclasses.Java Keywords32. Public: The ‘public’ keyword is another access modifier that allows one class to use a publicly defined class’s attributes or methods or etc., within itself.
Below is a publicly defined class ‘test.java’ and another class, class ‘Test2.java’, access it.Java KeywordsClass – Test2.javaJava Keywords33. Return: The ‘return’ keyword can be used as an execution end for a method, and also, it is used to return a value from a method.Java Keywords34. Short: The ‘short’ keyword is a type of data type that is used to hold the whole number ranging from -32768 to 32767.Java Keywords35. Static: The ‘static’ keyword is used to create a method static, which means that method can be called without creating its object.Java Keywords36. Super: The ‘super’ keyword is used to call the super or parent class or objects.Java Keywords37. Switch: The ‘switch’ keyword is used to create different scenarios into different cases and is used to select one out of them. The switch statement contains a value or expression, which then is compared with all the cases present, and the match one is selected.Java Keywords38. This: the ‘this’ keyword is used to refer to the current object of a method or a constructor.Java Keywords39. Throw: The ‘throw’ keyword is used to throw an exception message on the screen for the user.Java Keywords40. Throws: The ‘throws’ keyword is used when the programmer want to decide and throw a type of exception.41 specifically. Try: The ‘try’ keyword starts a ‘try-catch’ block. The ‘try’ block is where the exceptions are tested.Java Keywords42. Void: The ‘void’ keyword, when used with a method, specifies that the method will not have a return value.Java Keywords43. While: The ‘while’ keyword creates a loop with a condition in its statements. The loop is executed until the statement is true.Java Keywords

Keywords are the tokens in the Java programming language that are reserved and have special meaning. They have a reserved use and a predefined action in the language.

The above is the detailed content of Java Keywords. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1659
14
PHP Tutorial
1258
29
C# Tutorial
1232
24
Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and Functionality PHP vs. Python: Core Features and Functionality Apr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

See all articles