Reserved Words in Java Explained - Java Tutorial For Absolute Beginners
Coding River
In this video, I am talking about Reserved words in Java.
In the Java programming language reserved words are keywords that have a predefined meaning in the Java. So it means that you cannot use any of these words when naming a variable, method, class, or as any other identifier.
There are actually 51 reserved words in Java; Out of these 51 keywords, 49 are actually used in the code and only 2 are not used in the code. You do not necessarily need to memorize these keywords since. Due to their special functions in the language, most IDE like Eclipse or NetBeans for Java use syntax highlighting to display keywords in a different color in order to identify them easily.
If a reserved word was used as a variable, you would get an error or unexpected result.
Below is a list of reserved words in Java.
- abstract -Specifies that a class or method will be implemented later, in a subclass
- assert -Assert describes a predicate (a true–false statement) placed in a Java program to indicate that the developer thinks that the predicate is always true at that place.
- Boolean – A data type that can hold True and False values only
- break – A control statement for breaking out of loops
- byte – A data type that can hold 8-bit data values
- case – Used in switch statements to mark blocks of text
- catch – Catches exceptions generated by try statements
- char – A data type that can hold unsigned 16-bit Unicode characters
- class -Declares a new class
- continue -Sends control back outside a loop
- default -Specifies the default block of code in a switch statement
- do -Starts a do-while loop
- double – A data type that can hold 64-bit floating-point numbers
- else – Indicates alternative branches in an if statement
- enum – A Java keyword used to declare an enumerated type. Enumerations extend the base class.
- extends -Indicates that a class is derived from another class or interface
- final -Indicates that a variable holds a constant value or that a method will not be overridden
- finally -Indicates a block of code in a try-catch structure that will always be executed
- float -A data type that holds a 32-bit floating-point number
- for -Used to start a for loop
- if -Tests a true/false expression and branches accordingly
- implements -Specifies that a class implements an interface
- import -References other classes
- instanceof -Indicates whether an object is an instance of a specific class or implements an interface
- int – A data type that can hold a 32-bit signed integer
- interface – Declares an interface
- long – A data type that holds a 64-bit integer
- native -Specifies that a method is implemented with native (platform-specific) code
- new – Creates new objects
- null -Indica ... https://www.youtube.com/watch?v=KhAgNbiQN6M
27332344 Bytes