-
Table of Contents
- 50 KEYWORDS IN JAVA
- 1. public
- 2. private
- 3. static
- 4. final
- 5.
. void
- 6. class
- 7. interface
- 8. extends
- 9. implements
- 10. super
- 11. this
- 12. new
- 13. instanceof
- 14. package
- 15. import
- 16. try
- 17. catch
- 18. throw
- 19. throws
- 20. finally
- 21. break
- 22. continue
- 23. for
- 24. while
- 25. do
- 26. switch
- 27. case
- 28. default
- 29. synchronized
- 30. volatile
- 31. transient
- 32. native
- 33. strictfp
- 34. assert
- 35. enum
- 36. super()
- 37. this()
50 KEYWORDS IN JAVA
Java is one of the most popular programming languages in the world, known for its versatility and robustness. Understanding key Java keywords is essential for any developer looking to master the language. In this article, we will explore 50 important keywords in Java that every programmer should be familiar with.
1. public
The public keyword is an access modifier that allows a class, method, or field to be accessed by any other class.
2. private
The private keyword restricts access to the class, method, or field to only within the same class.
3. static
The static keyword indicates that a method or field belongs to the class itself, rather than to instances of the class.
4. final
The final keyword indicates that a variable cannot be changed once it has been initialized.
5. void
The void keyword is used to specify that a method does not return any value.
6. class
The class keyword is used to declare a class in Java.
7. interface
The interface keyword is used to declare an interface in Java, which contains abstract methods that must be implemented by classes that implement the interface.
8. extends
The extends keyword is used to indicate that a class is inheriting from another class.
9. implements
The implements keyword is used to indicate that a class is implementing an interface.
10. super
The super keyword is used to refer to the superclass of a class.
11. this
The this keyword is used to refer to the current instance of a class.
12. new
The new keyword is used to create a new instance of a class.
13. instanceof
The instanceof keyword is used to check if an object is an instance of a particular class or interface.
14. package
The package keyword is used to declare a package in Java, which is a namespace that organizes a set of related classes and interfaces.
15. import
The import keyword is used to import classes, interfaces, or packages into a Java program.
16. try
The try keyword is used to start a block of code that may throw an exception.
17. catch
The catch keyword is used to handle exceptions that are thrown in a try block.
18. throw
The throw keyword is used to explicitly throw an exception.
19. throws
The throws keyword is used to declare that a method may throw certain exceptions.
20. finally
The finally keyword is used to start a block of code that will always be executed, regardless of whether an exception is thrown.
21. break
The break keyword is used to exit a loop or switch statement.
22. continue
The continue keyword is used to skip the rest of the current iteration of a loop and start the next iteration.
23. for
The for keyword is used to create a for loop, which executes a block of code a specified number of times.
24. while
The while keyword is used to create a while loop, which executes a block of code as long as a specified condition is true.
25. do
The do keyword is used to create a do-while loop, which executes a block of code at least once, and then repeats as long as a specified condition is true.
26. switch
The switch keyword is used to create a switch statement, which allows for multiple possible execution paths based on the value of a variable.
27. case
The case keyword is used within a switch statement to define different cases based on the value of a variable.
28. default
The default keyword is used within a switch statement to define the default case if none of the other cases match.
29. synchronized
The synchronized keyword is used to create a synchronized block of code, which ensures that only one thread can access the block at a time.
30. volatile
The volatile keyword is used to indicate that a variable’s value may be changed by multiple threads simultaneously.
31. transient
The transient keyword is used to indicate that a variable should not be serialized when an object is serialized.
32. native
The native keyword is used to indicate that a method is implemented in platform-dependent code, such as C or C++.
33. strictfp
The strictfp keyword is used to restrict floating-point calculations to ensure consistent results across different platforms.
34. assert
The assert keyword is used to perform assertions in a Java program, which can help to identify bugs and errors during development.
35. enum
The enum keyword is used to declare an enumeration, which is a special type that represents a group of constants.
36. super()
The super() keyword is used to call the constructor of the superclass in a subclass.
37. this()
The this()




