{"id":99540,"date":"2021-02-01T11:00:00","date_gmt":"2021-02-01T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=99540"},"modified":"2021-09-14T13:24:13","modified_gmt":"2021-09-14T10:24:13","slug":"java-keywords-tutorial","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/","title":{"rendered":"Java Keywords Tutorial"},"content":{"rendered":"<h2 class=\"wp-block-heading\" id=\"h-1-introduction\">1. Introduction<\/h2>\n<p>In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some usage examples.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-2-what-is-a-keyword-in-java-and-why-do-we-need-them\">2. What is a Keyword in Java and why do we need them?<\/h2>\n<p>The Java Compiler uses some reserved words called Keywords to compile and run Java Programs. Each reserved word has a special meaning attached to it and is used while generating the java bytecode. For example: when we declare a variable as \u201cint\u201d, the java bytecode understands that a store\/load operation needs to be done.<\/p>\n<p>Using these keywords Java understands how to store, load, and use variables or identifiers in the programs. Keywords cannot be used as identifiers i.e. Class names, variables names, or method names in Java.<\/p>\n<p>Using a Java Keyword as an identifier name will result in a compiler error. Consider the following program.<\/p>\n<p><span style=\"text-decoration: underline\"><em>KeywordExample.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">public class KeywordExample{\n\n    public static void main(String[] args) {\n\t\tint boolean = 123;\n\t}\t\n}\n<\/pre>\n<p>If compiled using the command line, it results in a compile-time error as follows:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/compile_time_error.jpg\"><img decoding=\"async\" width=\"651\" height=\"298\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/compile_time_error.jpg\" alt=\"Java Keywords - Keyword as identifier\" class=\"wp-image-99549\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/compile_time_error.jpg 651w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/compile_time_error-300x137.jpg 300w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><figcaption>Keyword as identifier<\/figcaption><\/figure>\n<\/div>\n<p>If we use an IDE like example Eclipse or IntelliJ etc, it will prompt an error during compile time itself. For if we type out the same example in an IDE, we get the following error. Also, note that most IDEs will color the keyword in some color like maroon.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/eclipse_error.jpg\"><img decoding=\"async\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/eclipse_error.jpg\" alt=\"Java Keywords - Keyword as identifier\" class=\"wp-image-99550\" width=\"820\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/eclipse_error.jpg 836w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/eclipse_error-300x117.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/eclipse_error-768x299.jpg 768w\" sizes=\"(max-width: 836px) 100vw, 836px\" \/><\/a><figcaption>Keyword as identifier<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-3-how-many-keywords-in-java\">3. How many keywords in Java?<\/h2>\n<p>There are a total of 51 keywords in Java as of now. Java has added some keywords in the later versions as well. For example, the most recently added keyword is exported.<\/p>\n<p>Below are all the keywords, grouped by their categories. The categories are broadly 8 different categories:<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-3-1-data-types\">3.1 Data types<\/h3>\n<p><span>These are primitive data types that are used in Java. They are:<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>boolean<\/li>\n<li>byte<\/li>\n<li>char<\/li>\n<li>double<\/li>\n<li>float<\/li>\n<li>int<\/li>\n<li>long<\/li>\n<li>short<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-2-access-modifiers\">3.2 Access modifiers<\/h3>\n<p><span>Access modifiers are used with Classes, methods, and variables. They decide the scope\/visibility of the variable being used with them. E.g.: If a variable is marked as \u201cpublic\u201d, it is accessible from anywhere. The access modifiers are as follows:<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>public<\/li>\n<li>private<\/li>\n<li>protected<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-3-class-method-and-variable-modifiers\">3.3 Class, method, and variable modifiers<\/h3>\n<p><span> These are non-access modifiers. These can be used with classes, methods, and variables. These keywords define the behavior.<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>abstract<\/li>\n<li>class<\/li>\n<li>default<\/li>\n<li>extends<\/li>\n<li>&nbsp;final&nbsp;<\/li>\n<li>implements<\/li>\n<li>interface&nbsp;<\/li>\n<li>native<\/li>\n<li>new<\/li>\n<li>static&nbsp;<\/li>\n<li>strictfp<\/li>\n<li>synchronized&nbsp;<\/li>\n<li>transient<\/li>\n<li>var<\/li>\n<li>record&nbsp;<\/li>\n<li>volatile<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-4-package-control\">3.4 Package control<\/h3>\n<p><span>These are keywords used to create and import packages in Java. From Java 9 onwards a new keyword export has also been added to this list.<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>import<\/li>\n<li>package<\/li>\n<li>exports<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-5-flow-control\">3.5 Flow control<\/h3>\n<p><span>Flow control keywords are used to control the flow of execution of a Java program. These keywords are related to loops and conditional keywords<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>if<\/li>\n<li>else<\/li>\n<li>for<\/li>\n<li>while<\/li>\n<li>do<\/li>\n<li>switch<\/li>\n<li>case<\/li>\n<li>break<\/li>\n<li>continue<\/li>\n<li>instanceOf<\/li>\n<li>return<\/li>\n<li>default<\/li>\n<li>yield<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-6-enumeration\">3.6 Enumeration<\/h3>\n<p><span> Enum is a special class that represents a group of constants. The keyword related to the Enumeration is <\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>enum<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-7-error-handling\">3.7 Error handling<\/h3>\n<p><span> Error handling keywords are used for exception handling and for testing. The keywords are as follows:<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>assert<\/li>\n<li>catch<\/li>\n<li>try<\/li>\n<li>finally<\/li>\n<li>throw<\/li>\n<li>throws<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-8-others-miscellaneous\">3.8 Others\/Miscellaneous<\/h3>\n<p><span> These are some other keywords used in Java.<\/span><\/p>\n<ul class=\"wp-block-list\">\n<li>super<\/li>\n<li>this<\/li>\n<li>void<\/li>\n<\/ul>\n<p>Java does not use these keywords but has reserved them as keywords.<\/p>\n<ul class=\"wp-block-list\">\n<li>const<\/li>\n<li>goto<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-4-java-keyword-examples\">4. Java Keyword Examples<\/h2>\n<p>We will look at examples for Primitive data types and access modifiers. Then we will look at a sample application for understanding how to use the rest of the modifiers.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-4-1-primitive-data-types\">4.1 Primitive Data Types<\/h3>\n<p>Java is a strongly-typed language. This means that the user needs to declare a data type for every variable else Java cannot compile it. Primitive data types are the types which have a size range associated with them. They do not have any other methods that we can access. There are in total 8 primitive types in Java. The types with their size ranges are as follows<\/p>\n<figure class=\"wp-block-table aligncenter\">\n<table>\n<thead>\n<tr>\n<th class=\"has-text-align-left\" data-align=\"left\">Data type            <\/th>\n<th class=\"has-text-align-center\" data-align=\"center\">Storage size<\/th>\n<th class=\"has-text-align-center\" data-align=\"center\">Range of values<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">byte<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">8-bit<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">-128 to 127<\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">short<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">16-bit<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">-32768 to 32767<\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">int<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">32-bit<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">0 to 2<sup>32 <\/sup>-1&nbsp;(Java 8 and later)<\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">long<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">64-bit<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">0 to 2<sup>64 <\/sup>-1 (Java 8 and later)<\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">float<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">single-precision 32-bit IEEE 754 floating point<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">3.40282347 x 10<sup>38<\/sup> to 1.40239846 x 10<sup>-45<\/sup><\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">double<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">double-precision 64-bit IEEE 754 floating point<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">1.7976931348623157 x 10308 to 4.9406564584124654 x 10-324<\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">boolean<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">1 bit<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">true or false<\/td>\n<\/tr>\n<tr>\n<td class=\"has-text-align-left\" data-align=\"left\">char<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">16-bit Unicode character<\/td>\n<td class=\"has-text-align-center\" data-align=\"center\">&#8216;\\u0000&#8217; to &#8216;\\uffff&#8217;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<p>More information related to Java datatypes is available <a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/java\/nutsandbolts\/datatypes.html\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-4-1-1-declaration-of-primitive-types\">4.1.1 Declaration of primitive types.<\/h4>\n<p>The first three examples show the declaration of primitive data types.<\/p>\n<p><span style=\"text-decoration: underline\"><em>KeywordsApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">public class KeywordsApp{\n\n    public static void main(String[] args){\n        \/\/Simple primitive data type declarations\n        byte byteNum = 125; \n        System.out.println(\"The byte number is: \" + byteNum);\n\n        short shortNum = 32767;\n        System.out.println(\"The short number is: \" + shortNum);\n\n        int intNum = -20;\n        System.out.println(\"The integer is: \" + intNum);\n\n    }\n}\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/primitive_date_types_examples.jpg\"><img decoding=\"async\" width=\"817\" height=\"312\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/primitive_date_types_examples.jpg\" alt=\"Java Keywords - Primitive data types as keywords\" class=\"wp-image-99551\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/primitive_date_types_examples.jpg 817w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/primitive_date_types_examples-300x115.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/primitive_date_types_examples-768x293.jpg 768w\" sizes=\"(max-width: 817px) 100vw, 817px\" \/><\/a><figcaption>Primitive data types as keywords<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-4-1-2-overflow-or-underflow-errors\">4.1.2 Overflow or underflow errors<\/h4>\n<p>Java throws a compilation error when the user-entered value is less than the minimum or more than the maximum value allowed. The example is for short but the same rules apply for the other data types as well.<\/p>\n<p><span style=\"text-decoration: underline\"><em> KeywordsApp.java<\/em><\/span><\/p>\n<pre class=\"\u201dbrush:java\u201d\">public class KeywordsApp{\n\n    public static void main(String[] args){\n        \/\/Simple primitive data type declarations\n        \/\/ byte byteNum = 125; \n        \/\/ System.out.println(\"The byte number is: \" + byteNum);\n\n        short shortNum = 32767;\n       \/\/ System.out.println(\"The short number is: \" + shortNum);\n\n        \/\/int intNum = -20;\n        \/\/System.out.println(\"The integer is: \" + intNum);\n        \/\/ Example for overflow error \n        \n        short shortSum = shortNum + 4;\n        System.out.println(\"The sum is: \" + shortSum);\n        \n       \/\/ Example of underflow\n        short shortNum1 = -32767;\n        short newShort = shortNum1-10;\n\n    }\n}\n<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/incompatible_types_error.jpg\"><img decoding=\"async\" width=\"813\" height=\"500\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/incompatible_types_error.jpg\" alt=\"Java Keywords - Incompatible types error\" class=\"wp-image-99552\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/incompatible_types_error.jpg 813w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/incompatible_types_error-300x185.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/incompatible_types_error-768x472.jpg 768w\" sizes=\"(max-width: 813px) 100vw, 813px\" \/><\/a><figcaption>Incompatible types error<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-4-1-3-data-type-casting\">4.1.3 Data type casting<\/h4>\n<p>We can convert from one primitive data type to another by casting to a bigger data type. For example, we can get a floating-point number after the division of two integers by casting it to float.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span style=\"text-decoration: underline\"><em> KeywordsApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">public class KeywordsApp{\n\n    public static void main(String[] args){\n\n    \/\/Example fo transformation from one form to another.\n    int number1 = 3027;\n    int number2 = 100;\n\n    System.out.println(\"By normal division : \" + (number1\/number2));\n\n    float div = (float) number1 \/ number2;\n    System.out.println(\"The float division is: \" + div);\n    \n    }\n}<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/transform_example.jpg\"><img decoding=\"async\" width=\"810\" height=\"262\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/transform_example.jpg\" alt=\"Casting\" class=\"wp-image-99553\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/transform_example.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/transform_example-300x97.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/transform_example-768x248.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><figcaption>Casting<\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-4-2-access-modifiers\">4.2 Access modifiers<\/h3>\n<p>Access modifiers are keywords that Java uses to determine the scope or visibility. Access Modifiers can be used for classes, methods, and variables. There are many access modifiers but here we will look at the 2 most used access modifiers: private and public.<\/p>\n<p>A public modifier enables the class or variable or method to be accessible from anywhere, even across packages. Private is the most restrictive modifier. When something is marked private it cannot be accessed from anywhere else except where it is written.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-4-2-1-public-and-private-class\">4.2.1 Public and private class<\/h4>\n<p>The first package: testPackages1 has 2 classes, one public and one private. As a rule in Java, there can be only one public class in one .java file and it has to have the same name as the file. &nbsp;There is also another private class named HelperClass and a default class HelperClass2.<\/p>\n<p><span style=\"text-decoration: underline\"><em> AccessKeywords.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package testPackage1;\n\npublic class AccessKeywords {\n    private class HelperClass {\n     String nothingToDo =\"\";\n   }\n\n   \/\/Can be accessed\n   HelperClass hc = new HelperClass();\n\n}\n\n class Helper2{\n     \/\/cannot be accessed\n     HelperClass hc = new HelperClass();\n}<\/pre>\n<p><\/p>\n<p><span style=\"text-decoration: underline\"><em> AccessKeywordsApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package testPackage2;\n\nimport testPackage1.AccessKeywords;\n\npublic class AccessKeywordsApp {\n    public static void main(String[] args) {\n       \n        \/\/This can be accessed becuase class is public\n        AccessKeywords aKeywords = new AccessKeywords();\n\n        \/\/Private classes cannot be accessed\n        HelperClass help = new HelperClass();\n\n    }\n}\n<\/pre>\n<p>Compilation of the above program leads to the following output:<br \/>\u2022 Fails compilation with errors in both AccessKeywords.java and AccessKeywordsApp.java<br \/>\u2022 The public class declaration does not have an error.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/class_modifiers.jpg\"><img decoding=\"async\" width=\"810\" height=\"583\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/class_modifiers.jpg\" alt=\"Class modifier keywords example\" class=\"wp-image-99554\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/class_modifiers.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/class_modifiers-300x216.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/class_modifiers-768x553.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><figcaption>Class modifier keywords example<\/figcaption><\/figure>\n<\/div>\n<h4 class=\"wp-block-heading\" id=\"h-4-2-2-public-and-private-methods\">4.2.2 Public and private methods<\/h4>\n<p>The following example shows two methods one private and public. We try to access them in the other class, in the other package<\/p>\n<p><span style=\"text-decoration: underline\"><em> AccessKeywords.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package testPackage1;\n\npublic class AccessKeywords {\n\n    \/\/Can be accessed only inside this class\n    private int firstNum = 30;\n    \/\/can be accessed outside class and even package\n    public char ch = 'A';\n\n    \/\/Can be accessed only by this class\n    private int multiplyBy2(){\n        return firstNum * 2;\n    }\n\n    \/\/Can be accessed outside as well.\n    public int sumNumbers(int num1){\n        return num1 + multiplyBy2();\n   }\n\n}\n<\/pre>\n<p><\/p>\n<p><span style=\"text-decoration: underline\"><em> AccessKeywordsApp.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package testPackage2;\n\nimport testPackage1.AccessKeywords;\n\npublic class AccessKeywordsApp {\n    public static void main(String[] args) {\n       \n        \/\/This can be accessed becuase class is public\n        AccessKeywords aKeywords = new AccessKeywords();\n\n       \/\/Access to public methods\n        int result = aKeywords.sumNumbers(10);\n\n        System.out.println(\"Result is: \" + result);\n        \n       \/\/Private methods cannot be accessed\n       \/\/aKeywords.multiplyBy2();\n       \n    }\n}\n<\/pre>\n<p>When we try to access the multiplyBy2 method in the AccessKeywordsApp, it fails compilation. Once removed the program runs and executes without any issues since we can access all public methods from anywhere. The same rule applies for public and private variables.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/public_private_Methods.jpg\"><img decoding=\"async\" width=\"810\" height=\"316\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/public_private_Methods.jpg\" alt=\"Method modifier keywords\" class=\"wp-image-99555\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/public_private_Methods.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/public_private_Methods-300x117.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/public_private_Methods-768x300.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><figcaption>Method modifier keywords <\/figcaption><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\" id=\"h-4-3-rest-of-the-keywords\">4.3 Rest of the keywords<\/h3>\n<p>For looking at the rest of the keywords we will use a sample project called Library System. In this project, there is an option to View, Add, Edit and Search Books present in a fictional library.<\/p>\n<p>The app has the following classes:<\/p>\n<ul class=\"wp-block-list\">\n<li>ApplicationClass.java<\/li>\n<li>ApplicationConstants.java<\/li>\n<li>Book.java<\/li>\n<li>BookManager.java<\/li>\n<\/ul>\n<p>ApplicationClass.java is the class where the application runs, while the BookManager.java has the bulk of the functionality. Given below is the code for the ApplicationClass.java, BookManager.java and a small snippet of the Book.java classes. The full code is available at the end of the article.<\/p>\n<p>The javac command to compile the application is:<\/p>\n<pre class=\"brush:bash\">javac -cp lib\/commons-io-sources.jar LibraryPackage\/*.java<\/pre>\n<p>and to run <\/p>\n<pre class=\"brush:bash\">java -cp lib\/*;. LibraryPackage\/ApplicationClass<\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-4-3-1-the-code\">4.3.1 The code<\/h4>\n<p>The code for applicationClass.java and BookManager.java<\/p>\n<p><span style=\"text-decoration: underline\"><em> ApplicationClass.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package LibraryPackage;\n\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n\npublic class ApplicationClass {\n\n    public static void main(String[] args) {\n\n        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));\n\n        BookManager bm = new BookManager();\n        String inputName = \"\";\n\n        while (true) {\n            System.out.println(\"==== Book Manager ====\");\n            System.out.println(\"     1) View all Books\");\n            System.out.println(\"     2) Add a Book\");\n            System.out.println(\"     3) Edit a Book\");\n            System.out.println(\"     4) Search for a Book\");\n            System.out.println(\"     5) Exit\");\n            System.out.println(\"\");\n            System.out.print(\"Please choose from the options View, Add, Edit, Search or Exit:\");\n            try {\n                String str = input.readLine();\n                int choice = Options.getAction(str);\n\n                switch (choice) {\n                case 1:\n                    bm.viewAllBooks();\n                    break;\n                case 2:\n                    System.out.println(\"==== Add a Book ====\");\n                    bm.addBook();\n                    break;\n                case 3:\n                    System.out.println(\"==== Edit a Book ====\");\n                    bm.editBook();\n                    break;\n                case 4:\n                    System.out.println(\"Enter the name of the book to search:\");\n                    try {\n                        inputName = input.readLine();\n                        if (!inputName.isEmpty()) {\n                            bm.searchBook(inputName);\n                        }\n                    } catch (IOException e) {\n                        e.printStackTrace();\n                    }\n\n                    break;\n                case 5:\n                    System.out.println(\"All changes saved!\");\n                    input.close();\n                    System.exit(0);\n                    break;\n                default:\n                    System.out.println(\"Invalid choice!Please pick an option from View, Add, Edit, Search or Exit \");\n                    break;\n\n                }\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n\n        }\n\n    }\n\n    public static enum Options{\n        VIEW(1),\n        ADD(2),\n        EDIT(3),\n        SEARCH(4),\n        EXIT(5);\n        \n        private int action;\n\n        public static int getAction(String input){\n            int out = 0;\n            Options[] values = Options.values();\n\n            for(Options val : values){\n                if(input.toUpperCase().contains(val.name())){\n                    out = val.action; \n                }\n                   \n           }\n           return out;\n\n        }\n\n        Options(int val){\n            action = val;\n        }\n    }\n}\n<\/pre>\n<p><\/p>\n<p><span style=\"text-decoration: underline\"><em> BookManager.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package LibraryPackage;\n\nimport java.io.BufferedReader;\nimport java.io.File;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.FileWriter;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.nio.charset.Charset;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport org.apache.commons.io.input.ReversedLinesFileReader;\n\npublic class BookManager {\n\n    ArrayList books = new ArrayList();\n\n    public void viewAllBooks() {\n\n        loadAllBooks();\n        allBooksString();\n\n        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n        while (true) {\n            System.out.println(\"Please enter the ID of the book to see the details.Press Enter to exit \");\n            String in = null;\n            try {\n                in = br.readLine();\n                if (in.isEmpty() || in.equals(\"\")) {\n                    break;\n                } else {\n                    int bookId = Integer.parseInt(in);\n                    for (Book bk : books) {\n                        if (bk.getId() == bookId) {\n                            displayBookDetail(bk);\n                        }\n                    }\n\n                }\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n        }\n    }\n\n    \/**\n     * The method adds a new book to the library. The title,author and description\n     * is kept optional. If the user has not entered any details, then a space is\n     * inserted in the file.\n     *\/\n    public void addBook() {\n\n        String csvFile = ApplicationConstants.LIB_NAME;\n\n        \/\/ To get the latest id from the csv file\n        File inputFile = new File(csvFile);\n        Book bk = new Book();\n\n        try (ReversedLinesFileReader rf = new ReversedLinesFileReader(inputFile, Charset.defaultCharset());\n                FileWriter txtWriter = new FileWriter(ApplicationConstants.LIB_NAME, true);) {\n\n            String line = rf.readLine();\n            if (line != null) {\n                String[] lastLine = line.split(\",\");\n                \/\/ Auto-increment the ID in the library\n                bk.setId(Integer.parseInt(lastLine[0]) + 1);\n            } else {\n                bk.setId(1);\n            }\n\n            \/\/ Inputs from the user\n            System.out.println(\"======Please Enter the following information:\");\n            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n\n            System.out.println(\"Title:\");\n            String title = br.readLine();\n            if (!title.isEmpty()) {\n                bk.setTitle(title);\n            } else {\n                bk.setTitle(\" \");\n            }\n\n            System.out.println(\"Author:\");\n            String author = br.readLine();\n            if (!author.isEmpty()) {\n                bk.setAuthor(author);\n            } else {\n                bk.setAuthor(\" \");\n            }\n            System.out.println(\"Description:\");\n            String desc = br.readLine();\n            if (!desc.isEmpty()) {\n                bk.setDescription(desc);\n            } else {\n                bk.setDescription(\" \");\n            }\n\n            \/\/ Output or Save to file\n            txtWriter.write(\"\\n\");\n            txtWriter.write(bookToString(bk));\n\n            System.out.println(\"Book [\" + bk.getId() + \"] Saved.\");\n            System.out.println(\"================================\");\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n\n    }\n\n    \/**\n     * This method is used to edit a file already in the Library. All the fields\n     * except the ID can be changed. If the user does not change the detail of a\n     * particular field, then the field is set to its old value.\n     *\/\n    public void editBook() {\n\n        \/\/ To show all the books in the Lib\n        loadAllBooks();\n        allBooksString();\n\n        File f = new File(ApplicationConstants.LIB_NAME);\n\n        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));\n        try {\n            String newLine = \"\";\n            int index = -1;\n            while (true) {\n                System.out.println(\"Enter the book ID of the book you want to edit, to return press .\");\n                String input = in.readLine();\n                if (input.isEmpty() || input.equals(\"\")) {\n                    System.out.println(\"==================================\");\n                    break;\n                } else {\n                    int bookId = Integer.parseInt(input);\n                    for (Book bk : books) {\n                        index++;\n                        if (bk.getId() == bookId) {\n                            System.out.println(\n                                    \"Input the following information. To leave a field unchanged, hit \");\n                            System.out.println(\"Title[\" + bk.getTitle() + \"] :\");\n                            String title = in.readLine();\n                            if (!title.isEmpty()) {\n                                bk.setTitle(title);\n                            }\n                            System.out.println(\"Author[\" + bk.getAuthor() + \"] :\");\n                            String author = in.readLine();\n                            if (!author.isEmpty()) {\n                                bk.setAuthor(author);\n                            }\n                            System.out.println(\"Description[\" + bk.getDescription() + \"] :\");\n                            String desc = in.readLine();\n                            if (!desc.isEmpty()) {\n                                bk.setDescription(desc);\n                            }\n\n                            \/\/ this gives the line to be edited\n                            newLine = bookToString(bk);\n\n                            List lines = new ArrayList();\n                            lines = Files.readAllLines(Paths.get(ApplicationConstants.LIB_NAME\n),Charset.defaultCharset());\n                            \/\/ add the edited line to the list\n                            lines.set(index, newLine);\n\n                            \/\/ overwrite the file\n                            FileWriter fw = new FileWriter(f);\n                            Boolean first = true;\n                            for (String line : lines) {\n\n                                \/\/ To ensure that there are no extra line separators\n                                if (!first)\n                                    fw.write(System.lineSeparator());\n                                else\n                                    first = false;\n                                fw.write(line);\n                            }\n\n                            fw.close();\n                            break;\n                        }\n                    }\n\n                }\n\n            }\n\n        } catch (IOException e) {\n            \/\/ TODO Auto-generated catch block\n            e.printStackTrace();\n        }\n\n    }\n\n    \/\/ Searched through the library for a book using the title of the book.\n    public void searchBook(String inputName) {\n        \/\/ To ensure that Search can be the first operation\n        if (books.isEmpty()) {\n            loadAllBooks();\n        }\n        if (!books.isEmpty()) {\n            System.out.println(\n                            \"The following books matched your query. Enter the book ID to see more details, or  to return.\");\n            for (Book bk : books) {\n                \/\/ To ensure that any string irrespective of the capitalization will be searched\n                if (bk.getTitle().toLowerCase().contains(inputName.toLowerCase())) {\n                    System.out.println(bookDetail(bk));\n                    \/\/break;\n                }\n            }\n            while (true) {\n                System.out.println(\"Please enter the ID of the book to see the details.Press Enter to exit \");\n                String in = null;\n                BufferedReader br = new BufferedReader(new InputStreamReader(System.in));\n                try {\n                    in = br.readLine();\n                    if (in.isEmpty() || in.equals(\"\")) {\n                        System.out.println(\"==================================\");\n                        break;\n                    } else {\n                        int bookId = Integer.parseInt(in);\n                        for (Book bk : books) {\n                            if (bk.getId() == bookId) {\n                                displayBookDetail(bk);\n                                break;\n                            }\n                        }\n                    }\n                } catch (IOException e) {\n                    e.printStackTrace();\n                }\n            }\n        } else {\n            System.out.println(\"No books in the Library to search\");\n        }\n    }\n\n    \/* Util Functions *\/\n    private void displayBookDetail(Book bk) {\n        System.out.println(\"=====Book Details======\");\n        System.out.println(\"Book ID:      \" + bk.getId());\n        System.out.println(\"Title:        \" + bk.getTitle());\n        System.out.println(\"Author:       \" + bk.getAuthor());\n        System.out.println(\"Description:  \" + bk.getDescription());\n        System.out.println(\"===================================================\");\n    }\n\n    private String bookDetail(Book bk) {\n        return \"[\" + bk.getId() + \"] \" + bk.getTitle();\n    }\n\n    private void allBooksString() {\n\n        if (!books.isEmpty()) {\n            for (Book bk : books) {\n                System.out.println(\"[\" + bk.getId() + \"] \" + bk.getTitle());\n            }\n        } else {\n            System.out.println(\"No books to show!Please add books to the library\");\n        }\n\n    }\n\n    \/\/ Format a book object to a string to be written to a file\n    private String bookToString(Book b) {\n        return b.getId() + \",\" + b.getTitle() + \",\" + b.getAuthor() + \",\" + b.getDescription();\n    }\n\n    \/\/ Get all the books in the file and store in a collection\n    private void loadAllBooks() {\n        String txtFile = ApplicationConstants.LIB_NAME;\n        String line = \"\";\n        String cvsSplitBy = \",\";\n        \/\/ Ensuring books do not reappear in the list\n        books.clear();\n        try (BufferedReader br = new BufferedReader(new FileReader(txtFile));) {\n\n            while ((line = br.readLine()) != null) {\n                \/\/ use comma as separator\n                String[] book = line.split(cvsSplitBy);\n                Book bk = new Book();\n\n                if (book != null) {\n                    bk.setId(Integer.parseInt(book[0]));\n                    if (book[1] != null || !book[1].equals(\"\") || !book[1].isEmpty()) {\n                        bk.setTitle(book[1]);\n                    } else {\n                        bk.setTitle(\" \");\n                    }\n                    if (book[2] != null || !book[2].equals(\"\") || !book[2].isEmpty()) {\n                        bk.setAuthor(book[2]);\n                    } else {\n                        bk.setAuthor(\" \");\n                    }\n                    if (book[3] != null || !book[3].equals(\"\") || !book[3].isEmpty()) {\n                        bk.setDescription(book[3]);\n                    } else {\n                        bk.setDescription(\" \");\n                    }\n\n                    books.add(bk);\n                }\n            }\n\n        } catch (FileNotFoundException e) {\n            e.printStackTrace();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n\n    }\n\n}\n<\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-4-3-2-keywords-seen\">4.3.2 Keywords seen <\/h4>\n<p>The above files have most of the important Java keywords. For example, in the ApplicationClass.java file, we see the keywords<\/p>\n<ul class=\"wp-block-list\">\n<li>package<\/li>\n<li>Import<\/li>\n<li>Try<\/li>\n<li>catch<\/li>\n<li>enum<\/li>\n<li>while<\/li>\n<li>switch<\/li>\n<li>default<\/li>\n<li>case<\/li>\n<li>break<\/li>\n<\/ul>\n<p>The BookManager file shows how to use <\/p>\n<ul class=\"wp-block-list\">\n<li>if<\/li>\n<li>else<\/li>\n<li>for<\/li>\n<li>while<\/li>\n<\/ul>\n<p>The Book.java file has the super and this keywords used.<\/p>\n<p>Some screens of the application are as follows:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/Screens1.jpg\"><img decoding=\"async\" width=\"810\" height=\"587\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/Screens1.jpg\" alt=\"View and Add Screens\" class=\"wp-image-99556\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/Screens1.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/Screens1-300x217.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/Screens1-768x557.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><figcaption>View and Add Screens<\/figcaption><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/screens2.jpg\"><img decoding=\"async\" width=\"691\" height=\"706\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/screens2.jpg\" alt=\"Application screens\" class=\"wp-image-99557\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/screens2.jpg 691w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/screens2-294x300.jpg 294w\" sizes=\"(max-width: 691px) 100vw, 691px\" \/><\/a><figcaption>Default and edit<\/figcaption><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/search_screen.jpg\"><img decoding=\"async\" width=\"810\" height=\"593\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/search_screen.jpg\" alt=\"Application screens\" class=\"wp-image-99559\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/search_screen.jpg 810w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/search_screen-300x220.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/search_screen-768x562.jpg 768w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><figcaption>Application screens<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-5-summary\">5. Summary<\/h2>\n<p>In this article, we looked at Java keywords, their usage, and categories. We saw how to use Java keywords and how they interact with each other through an app. Java Keywords are essential to Java and are we use them in almost every single line of code as seen in the above examples. They are the \u201cNuts and Bolts\u201d of Java.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-6-download-the-source-code\">6. Download the Source Code<\/h2>\n<p>This was a tutorial on Java Keywords, the nuts and bolts of Java.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2021\/01\/JavaKeywordsTutorial.zip\"><strong> Java Keywords Tutorial<\/strong><\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some usage examples. 2. What is a Keyword in Java and why do we need them? The Java Compiler uses some reserved words called Keywords to compile and &hellip;<\/p>\n","protected":false},"author":232,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[189],"class_list":["post-99540","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-core-java-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Keywords Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Keywords Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-01T09:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-14T10:24:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Reshma Sathe\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Reshma Sathe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\"},\"author\":{\"name\":\"Reshma Sathe\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74\"},\"headline\":\"Java Keywords Tutorial\",\"datePublished\":\"2021-02-01T09:00:00+00:00\",\"dateModified\":\"2021-09-14T10:24:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\"},\"wordCount\":1361,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"core java\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\",\"name\":\"Java Keywords Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2021-02-01T09:00:00+00:00\",\"dateModified\":\"2021-09-14T10:24:13+00:00\",\"description\":\"1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java Keywords Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74\",\"name\":\"Reshma Sathe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png\",\"caption\":\"Reshma Sathe\"},\"description\":\"I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.\",\"sameAs\":[\"www.linkedin.com\/in\/reshma-sathe\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/reshma-sathe\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Keywords Tutorial - Java Code Geeks","description":"1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Java Keywords Tutorial - Java Code Geeks","og_description":"1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some","og_url":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2021-02-01T09:00:00+00:00","article_modified_time":"2021-09-14T10:24:13+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Reshma Sathe","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Reshma Sathe","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/"},"author":{"name":"Reshma Sathe","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74"},"headline":"Java Keywords Tutorial","datePublished":"2021-02-01T09:00:00+00:00","dateModified":"2021-09-14T10:24:13+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/"},"wordCount":1361,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["core java"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/","url":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/","name":"Java Keywords Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2021-02-01T09:00:00+00:00","dateModified":"2021-09-14T10:24:13+00:00","description":"1. Introduction In this article, we will look at words Java considers as Keywords. We will explore why they are used and what they are along with some","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-keywords-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"Java Keywords Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/079aa9a12c7b8ebea3391ebeb6036a74","name":"Reshma Sathe","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/08\/reshma_sathe-96x96.png","caption":"Reshma Sathe"},"description":"I am a recent Master of Computer Science degree graduate from the University Of Illinois at Urbana-Champaign.I have previously worked as a Software Engineer with projects ranging from production support to programming and software engineering.I am currently working on self-driven projects in Java, Python and Angular and also exploring other frontend and backend technologies.","sameAs":["www.linkedin.com\/in\/reshma-sathe"],"url":"https:\/\/examples.javacodegeeks.com\/author\/reshma-sathe\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/99540","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/232"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=99540"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/99540\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=99540"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=99540"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=99540"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}