{"id":16419,"date":"2020-07-04T11:07:16","date_gmt":"2020-07-04T05:37:16","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/"},"modified":"2025-02-12T01:01:22","modified_gmt":"2025-02-11T19:31:22","slug":"java-tutorial-for-beginners","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/","title":{"rendered":"Java Tutorial for Beginners"},"content":{"rendered":"\n<p>To date, Java is being used to develop many applications like Mobile and Web-based applications, Enterprise Applications, Big Data Technologies, etc. Java has seen significant growth over the years and has a bright future ahead. Without further ado, let\u2019s begin with the Java Tutorial.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"what-is-java\"><strong>What is Java?<\/strong><\/h2>\n\n\n\n<p>Java is a high-level, robust, and object-oriented programming language that was initially developed by Sun Microsystems (now a subsidiary of Oracle) in 1995.&nbsp;<\/p>\n\n\n\n<p>It follows the principle of <strong>WORA <\/strong>(Write Once Run Anywhere) \u2013 you can run a java program as many times as you want on a Java supported platform after it is compiled. There is no need for recompilation.&nbsp;<\/p>\n\n\n\n<p>A platform is any hardware or software environment where you can run your programs. Java is known as a platform because it has a runtime environment (JRE) and API.&nbsp;<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy Pro<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-java-programming\" class=\"courses-cta-title-link\">Java Programming Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Learn Java the right way! Our course teaches you essential programming skills, from coding basics to complex projects, setting you up for success in the tech industry.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>16.05 Hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>3 Projects<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-java-programming\" class=\"courses-cta-button\">\n                Learn Java Programming\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<p>Also you can learn <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/java-programming-in-hindi\" target=\"_blank\" rel=\"noreferrer noopener\">free Java Programming Course in Hindi with Certificate<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"history-of-java\"><strong>History of Java<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1991: Java was first designed for the digital cable television industry<\/li>\n\n\n\n<li>It was initially known as the Green Team. It was designed by James Gosling and his team members, Mike Sheridan and Patrick Naughton<\/li>\n\n\n\n<li>Later it got renamed to Oak based on the Oaktree outside James Gosling\u2019s Office<\/li>\n\n\n\n<li>1995: Oak got changed to Java based on the island in Indonesia from which the team used to have coffee<\/li>\n\n\n\n<li>Java was included in Time magazine\u2019s \u201cTop Ten Best Product of 1995\u201d<\/li>\n\n\n\n<li>1996: JDK 1.0 got released<\/li>\n<\/ul>\n\n\n\n<p>Let\u2019s move forward to the next topic in this Java tutorial to discuss Java\u2019s features and applications.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"features-of-java\"><strong>Features of Java<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Simplicity<\/strong>: It is very easy to learn as syntax is similar to previously existing languages like C and C++. It has removed complex and rarely used features, such as explicit pointers, operator overloading, etc.&nbsp;<\/li>\n\n\n\n<li><strong>Object-oriented<\/strong>: Java is based on objects which imitate real-world problems. It supports four pillars of the object-oriented language, i.e., Inheritance, Polymorphism, Abstraction and Encapsulation.<\/li>\n\n\n\n<li><strong>Platform Independent<\/strong>: It has its own virtual machine and converts the code into bytecode which can run on a Java supported platform.<\/li>\n\n\n\n<li><strong>Portability: <\/strong>As Java is platform-independent, any Java bytecode written on one platform can easily be carried into another platform.&nbsp;<\/li>\n\n\n\n<li><strong>Secured<\/strong>: Java is way more secured because it has its own box responsible for handling its execution. It does not support pointers and multiple inheritances, which can cause ambiguity or lead programs to crash.<\/li>\n\n\n\n<li><strong>Robust: <\/strong>Java is robust, which means powerful because it has strong memory management, automatic garbage collection, exception handling, and type checking mechanism.&nbsp;<\/li>\n\n\n\n<li><strong>Efficiency<\/strong>: It is much more efficient because it uses a JIT(Just In Time) compiler that basically utilises the best of 2 worlds, i.e., compiler and interpreter.<\/li>\n\n\n\n<li><strong>Distributed: <\/strong>Java facilitates us to create distributed applications using RMI (Remote Method Invocation) and EJB (Enterprise Java Beans). Using these Java features, you could access files by calling the methods from any machine on the web. Internet Explorer is an example of a distributed application.<\/li>\n\n\n\n<li><strong>Multi-threaded<\/strong>: Java supports thread, which basically allows multiple tasks to execute concurrently without occupying much memory.<\/li>\n\n\n\n<li><strong>Dynamic: <\/strong>Java is a dynamic language that supports the dynamic loading of classes. Using Java, you can adapt to an evolving environment supporting dynamic memory allocation, reducing memory wastage and improving the application\u2019s performance.<\/li>\n<\/ul>\n\n\n\n<p>Mastering this logic is a 'survival skill' for any modern developer, much like keeping a clean and organized Excel dashboard for your business. If you want a clear, no-headache roadmap to master these essentials, check out our <strong><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/java-programming\" target=\"_blank\" rel=\"noreferrer noopener\">free Java Course<\/a><\/strong>. It ensures you have a rock-solid foundation before you tackle complex software architecture.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Also Read:<\/strong> <a href=\"https:\/\/www.mygreatlearning.com\/blog\/why-is-java-platform-independent\/\">Why is Java Platform Independent?<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Learn Java Programming For Beginners | Core Java Tutorial | Java Basics | Great Learning\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/ZYwHJ1LiKZY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"applications-of-java\"><strong>Applications of Java<\/strong><\/h2>\n\n\n\n<p>According to Sun Microsystems, numerous devices currently run on Java. A few examples are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Desktop Applications:<\/strong> Acrobat Reader, Media Player, Antivirus, etc.<\/li>\n\n\n\n<li><strong>Web Applications: <\/strong>JSP, Spring, Hibernate, Servlet, Struts, etc.<\/li>\n\n\n\n<li><strong>Mobile Applications: <\/strong>Android, Java ME, Kotlin, etc.<\/li>\n\n\n\n<li><strong>Enterprise Applications:<\/strong> Banking Applications. EJB is used to create these applications.<\/li>\n\n\n\n<li><strong>Big Data Technologies: <\/strong>Hadoop<\/li>\n\n\n\n<li><strong>Testing:<\/strong> Selenium<\/li>\n\n\n\n<li><strong>Scientific Applications:<\/strong> MATLAB<\/li>\n\n\n\n<li><strong>Gaming Applications:<\/strong> 2D and 3D<\/li>\n\n\n\n<li><strong>Embedded Systems<\/strong><\/li>\n\n\n\n<li><strong>Robotics<\/strong><\/li>\n<\/ul>\n\n\n\n<p>And the list goes on. Numerous applications currently exist and run on Java. Java turned out to be one of the widely used programming languages in today\u2019s world. Working on <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/java-projects\" target=\"_blank\" rel=\"noreferrer noopener\">projects based on Java<\/a> will also help you understand the applications of Java. <\/p>\n\n\n\n<p>Now, let\u2019s head into the practical stuff and begin with the procedure to install Java on your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"difference-between-jdk-jre-and-jvm\"><strong>Difference between JDK, JRE and JVM&nbsp;<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>JVM: Java Virtual Machine<\/strong>\n<ul class=\"wp-block-list\">\n<li>This is a virtual(abstract) machine that holds all java executions<\/li>\n\n\n\n<li>It doesn't exist in reality.<\/li>\n\n\n\n<li>It also manages heap memory, garbage collector, etc.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>JRE: Java Runtime environment<\/strong>\n<ul class=\"wp-block-list\">\n<li>It is responsible for running pre-compiled java programs<\/li>\n\n\n\n<li>It contains all files and libraries to facilitate the running of java code<\/li>\n\n\n\n<li>It can't help one in development.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>JDK: Java Development toolkit<\/strong>\n<ul class=\"wp-block-list\">\n<li>This is a software that helps one in the development of Java applications.<\/li>\n\n\n\n<li>It is basically JRE+Development tools<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-of-java\"><strong>Installation of Java<\/strong><\/h2>\n\n\n\n<p>Now that you have a basic understanding of Java, let\u2019s move on to install Java in your system.<\/p>\n\n\n\n<p><strong>Step-1: <\/strong>You need to install <strong>Java JDK<\/strong> first. Open your search engine on your web browser and type \u201cJava JDK download\u201d in the search bar. Next, click on the \u201cJava SE Downloads\u201d link from Oracle, as shown below.<\/p>\n\n\n\n<p>For easier access, click on this <a href=\"https:\/\/www.oracle.com\/java\/technologies\/javase-jdk16-downloads.html\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>download link for Java JDK<\/strong><\/a> downloads.&nbsp;<\/p>\n\n\n\n<p>You will be redirected to the official webpage of Java SE Downloads.<\/p>\n\n\n\n<p><strong>Step-2: <\/strong>Next, click on the \u201cJDK Download\u201d link to download Java SE Development Kit.<\/p>\n\n\n\n<p>You will be redirected to the following page:<\/p>\n\n\n\n<p><strong>Step-3:<\/strong> As you can see in the above image, the latest Java SE version is 16. Now, scroll down to the downloads links of various platforms. You have Linux, macOS, and Windows. Choose the platform you are currently using. I use Windows, and I will demonstrate how to set up Java on your Windows platform.<\/p>\n\n\n\n<p>As shown in the above image highlighted in red, click on the \u201cWindows x64 Installer\u201d download button to download the Java JDK for Windows. Accept the license agreement, and your file will be downloaded.<\/p>\n\n\n\n<p><strong>Step-4:<\/strong> Once the software is downloaded, open the file to run the setup. An installation wizard window will appear. Choose \u2018Next\u2019 to move further into the installation process.<\/p>\n\n\n\n<p><strong>Step-5:<\/strong> Now, you will be asked to choose the destination folder to install the software. If you don\u2019t want to change the location, you can simply click on the \u2018Next\u2019 button. If you wish to change, simply click on the \u2018Change\u2019 button and choose your desired location. I recommend not to change because you need to set up an environment path variable for Java, which I will explain later in the next section.<\/p>\n\n\n\n<p>Java will be installed on your computer. After the installation, the final window will appear as shown below:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"setting-up-java-jdk-environment-path-in-windows\"><strong>Setting up Java JDK Environment Path in Windows<\/strong><\/h2>\n\n\n\n<p>Setting up the JAVA environment path variable will install Java globally on your system, and you can work on Java programs anywhere across your computer or system.<\/p>\n\n\n\n<p><strong>Step-1: <\/strong>Open \u201cControl Panel\u201d and click on: System and Security &gt; System &gt; Advanced system settings. A window will pop up on your screen, as shown below:<\/p>\n\n\n\n<p><strong>Step-2: <\/strong>Under \u2018System Variables\u2019, select \u201cPath\u201d and click on the \u201cEdit\u201d button.&nbsp;<\/p>\n\n\n\n<p><strong>Step-3:<\/strong> Next, click on the \u2018New\u2019 button to add the Java JDK bin path, as shown below:<\/p>\n\n\n\n<p><strong>Step-4:<\/strong> Now, open the JDK folder where you\u2019ve installed it and open the \u2018bin\u2019 folder.<\/p>\n\n\n\n<p>Copy the above path and paste it into the path variable, and click \u2018OK\u2019, as shown below:<\/p>\n\n\n\n<p><strong>Step-5:<\/strong> Later, under \u2018System Variables\u2019, click \u2018New\u2019 and add the following path:<\/p>\n\n\n\n<p>Now, click the \u2018OK\u2019 button. Java Home path is created. Now, click the \u2018OK\u2019 button, and the Java JDK path is successfully completed.&nbsp;<\/p>\n\n\n\n<p>You can now execute your Java programs across your system. To verify whether Java is successfully installed or not, open your command prompt and type the following command:<\/p>\n\n\n\n<p>java -version<\/p>\n\n\n\n<p>You will get the Java version information displayed in the command prompt, as shown below:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"java-hello-world-program\"><strong>Java Hello World Program <\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>public class MyFirstCode {\n\tpublic static void main (String&#091;] args) {\n\t\t\/\/to print on console\nSystem.out.println(\"Hello World!\");\n\t}\n}\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Everything bold is a keyword which are words with some fixed meaning<\/li>\n\n\n\n<li>\u2018Class\u2019 is used to declare class in Java<\/li>\n\n\n\n<li>\u2018Public\u2019 is an access modifier which allows visibility to all<\/li>\n\n\n\n<li>\u2018Static\u2019 doesn't need object to get called and main gets called by JVM<\/li>\n\n\n\n<li>\u2018Void\u2019 means that function will not return anything<\/li>\n<\/ul>\n\n\n\n<p>Now, since we have some understanding of code, for running the code following are the steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>After setting up your environment, open cmd<\/li>\n\n\n\n<li>To compile, type javac MyFirstCode.java&nbsp;<\/li>\n\n\n\n<li>To run, type java MyFirstCode<\/li>\n<\/ol>\n\n\n\n<p>This will print your output: Hello World!<\/p>\n\n\n\n<p>To test the understanding more better, take <a href=\"https:\/\/www.mygreatlearning.com\/blog\/java-quiz\/\">Java Quiz<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"variables\"><strong>Variables<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variable is the name of a memory location where the data is stored.<\/li>\n\n\n\n<li><strong>Syntax<\/strong>:&nbsp; datatype varname = val; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/li>\n<\/ul>\n\n\n\n<p> &nbsp;&nbsp;&nbsp;<strong>Example<\/strong>: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class VariableDemo {\n\tpublic static void main (String&#091;] args) {\n\t\t\/\/var declaration and initialization\n\t\tint roll_num=23;\n\t\tString first_name=\"adam\";\n\t\t\n\t\t\/\/just declaration\n\t\tint marks;\n\t\t\n\t\t\/\/later initialization\n\t\tmarks=89;\nSystem.out.println(\"Hi I am \"+first_name+\" roll_no \"+roll_num+\" and I scored \"+marks);\n\t}\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Hi I am adam rollno 23 and I scored 89<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"naming-convention\"><strong>Naming Convention<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variable names should begin with a letter, $, or an underscore(_)<\/li>\n\n\n\n<li>The first character can be then followed by any combination of letters or digits<\/li>\n\n\n\n<li>A variable name cannot be the same as any keyword as they are reserved for special purposes<\/li>\n\n\n\n<li>Variable names case sensitive\n<ul class=\"wp-block-list\">\n<li>Eg: valid- apple, _name, $address1<\/li>\n\n\n\n<li>Eg: invalid- 123apple, *roll, @email<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>There are <strong>3 types of variable<\/strong>s in Java<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"instance-variable\"><strong>Instance variable<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variable declared outside of any methods but within the class<\/li>\n\n\n\n<li>Can be accessed by the all the methods of class irrespective of its access specifier&nbsp;<\/li>\n\n\n\n<li>Every object of the class gets its own original copy of variable<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"static-variable\"><strong>Static Variable <\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Also known as class variables<\/li>\n\n\n\n<li>Variables declared as static, maintains a single copy in memory and is shared by all the objects of the class<\/li>\n\n\n\n<li>They can be directly called using class name as classname.var_name<\/li>\n\n\n\n<li>Non-static methods can't access or manipulate static variables<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"local-variable\"> <strong>Local variable<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Variables defined inside methods fall into this category.<\/li>\n\n\n\n<li>They are accessible in the scope where it is declared.<\/li>\n\n\n\n<li>They remain hidden outside of their methods.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class VariableDemo  {\n\tpublic static void main (String&#091;] args) {\n\t    int i=100;\/\/instance variable  \n        static int j=200;\/\/static variable  \n        \n        void method(){  \n        int k=300;\/\/local variable  \n            } \t\n      }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"operators\"><strong>Operators<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"unary-operators\"><strong>Unary operators<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It needs one operand<\/li>\n\n\n\n<li>We have 2 major operators here i.e, increment and decrement and each one have 2 variations of postfix and prefix<\/li>\n\n\n\n<li><strong>Increment <\/strong>- to increase the value by 1\n<ul class=\"wp-block-list\">\n<li>postfix: first assign then increment<\/li>\n\n\n\n<li>prefix: first increment then assign<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Decrement <\/strong>- to decrease the value by 1\n<ul class=\"wp-block-list\">\n<li>postfix: first assign then decrement<\/li>\n\n\n\n<li>prefix: first decrement then assign<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\"><\/h4>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class UnaryDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a,b,c,d;\n\t    a=b=c=d=5;\n\t    a++;\n\t    ++b;\n\t    c--;\n\t    --d;\n\t\tSystem.out.println(\"a= \"+a);\n\t\tSystem.out.println(\"b= \"+b);\n\t\tSystem.out.println(\"c= \"+c);\n\t\tSystem.out.println(\"d= \"+d);\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a= 6\nb= 6\nc= 4\nd= 4<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"arithmetic-operators\"><strong>Arithmetic operators<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It comprises all binary arithmetic operations like add, subtract, multiply, divide etc.<\/li>\n\n\n\n<li>Another addition operator is modulus(%), which gives you the remainder.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ArithmeticDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a,b,c,d;\n\t    a=6+5;\n\t    b=6-5;\n\t    c=6*5;\n\t    d=6\/5;\n\t\tSystem.out.println(\"a= \"+a);\n\t\tSystem.out.println(\"b= \"+b);\n\t\tSystem.out.println(\"c= \"+c);\n\t\tSystem.out.println(\"d= \"+d);\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong> Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a= 11\nb= 1\nc= 30\nd= 1<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"shift-operators\"><strong>Shift operators<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Two variations - left and right shift<\/li>\n\n\n\n<li><strong>left shift<\/strong>: shift bits in left direction for specified value<\/li>\n\n\n\n<li><strong>right shift<\/strong>: shift bits in right direction for specified value<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ShiftDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a,b;\n\t    a=b=8;\n\t    a&lt;&lt;=2;\n\t    b&gt;&gt;=2;\n\t\tSystem.out.println(\"a= \"+a);\n\t\tSystem.out.println(\"b= \"+b);\n\t\n\t}\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a= 32\nb= 2<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"relational-operators\"> <strong>Relational operators<\/strong> <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It comprises operators for comparisons<\/li>\n\n\n\n<li>There are operators to check inequality i.e., &lt; ,&gt;, &lt;=, &gt;=<\/li>\n\n\n\n<li>For equality check, we have 2 operators i.e., == and !=<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class RelationalDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a,b,c;\n\t    a=1;\n\t    b=2;\n\t    c=1;\n\t\tSystem.out.println(\"a&lt;b \"+ (a&lt;b));\n\t\tSystem.out.println(\"a&gt;b \"+ (a&gt;b));\n\t\tSystem.out.println(\"a&lt;=b \"+ (a&lt;=b));\n\t\tSystem.out.println(\"a&gt;=c \"+ (a&gt;=c));\n\t    System.out.println(\"a!=b \"+ (a!=b));\n\t\tSystem.out.println(\"a==c \"+ (a==c));\n\t}\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a&lt;b true\na&gt;b false\na&lt;=b true\na&gt;=c true\na!=b true\na==c true<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bitwise-operators\"> <strong>Bitwise operators<\/strong> <\/h3>\n\n\n\n<p>It computes by going bit by bit. Both sides are checked irrespective of what the first expression computes to. Four major bit operators are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&amp; <\/strong>- bitwise and, which returns 1 if both bits are 1 else 0.<\/li>\n\n\n\n<li><strong>| <\/strong>- bitwise or, which returns 1 if either of bits is 1 else 0.<\/li>\n\n\n\n<li><strong>^ <\/strong>- bitwise xor, which returns 1 if both bits are different else 0.<\/li>\n\n\n\n<li><strong>~ <\/strong>- bitwise not, which changes 1 to 0 and vice versa.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class BitwiseDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a,b;\n\t    a=1;\n\t    b=2;\n\t\tSystem.out.println(\"a&amp;b  = \"+ (a&amp;b));\n\t\tSystem.out.println(\"a|b  = \"+ (a|b));\n\t\tSystem.out.println(\"a^b  = \"+ (a^b));\n\t\tSystem.out.println(\"~a  = \"+ (~a));\n\t   \n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a&amp;b = 0\na|b = 3\na^b = 3\n~a = -2<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"logical-operators\"><strong>Logical operators<\/strong><\/h3>\n\n\n\n<p>These are used for conditions comparison that basically checks for the validity of them. They are also used in loops as part of termination conditions. If the first condition is enough to give the final verdict, it will not evaluate the second one. <\/p>\n\n\n\n<p>There are 3 logical operators:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>&amp;&amp; <\/strong>- logical AND, returns true when both conditions evaluate to true<\/li>\n\n\n\n<li><strong>|| <\/strong>- logical OR, returns true when either of the conditions evaluates to true<\/li>\n\n\n\n<li><strong>! <\/strong>- logical not, return true when the condition evaluates to false<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class LogicalDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a,b;\n\t    a=1;\n\t    b=2;\n\t\tSystem.out.println(\"a==1 &amp;&amp; b==1 \"+ (a==1 &amp;&amp; b==1));\n\t\tSystem.out.println(\"a==1 || b==1 \"+ (a==1 || b==1));\n\t\tSystem.out.println(\"!a \"+ !(a==1));\n\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a==1 &amp;&amp; b==1 false\na==1 || b==1 true\n!a false <\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"assignment-operator\"><strong>Assignment operator&nbsp;<\/strong><\/h3>\n\n\n\n<p><strong>Assignment operator(=)<\/strong> is used to assign right-hand side value to the left-hand side variable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"ternary-operator\"><strong>Ternary operator(?:)<\/strong> <\/h3>\n\n\n\n<p>An alternative of if-else. Condition is placed before '?' and if evaluates to true then LHS of the colon gets executed else RHS of the colon will be executed.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class MiscDemo {\n\tpublic static void main (String&#091;] args) {\n\t    int a;\n\t    \/\/assignment operator\n\t    a=1;\n\t\tSystem.out.println(\"(a==1?\"expression is true\":\"expression is false\" = n \"+ (a==1?\"expression is true\":\"expression is false\"));\n\t\t\n\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">(a==1?\"expression is true\":\"expression is false\" =&nbsp;\nexpression is true<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"primitive-data-types-in-java\"><strong>Primitive Data types in Java&nbsp;<\/strong><\/h2>\n\n\n\n<p>There are different types of data that one deals with in real life. To process them we need different types of containers or data types as storage. In java, there are <strong>8 primitive<\/strong> data types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>byte <\/strong>- size is 1 byte and by default, it holds 0<\/li>\n\n\n\n<li><strong>int <\/strong>- size is 4 byte and by default, it holds 0<\/li>\n\n\n\n<li><strong>short <\/strong>- size is 2 byte and by default, it holds 0<\/li>\n\n\n\n<li><strong>long <\/strong>- size is 8 byte and by default it holds 0L<\/li>\n\n\n\n<li><strong>char <\/strong>- size is 2 byte and by default, it holds 'u0000'<\/li>\n\n\n\n<li><strong>boolean <\/strong>- size is 1 bit and by default it holds false<\/li>\n\n\n\n<li><strong>float <\/strong>- size is 4 byte and by default it holds 0.0f<\/li>\n\n\n\n<li><strong>double <\/strong>- size is 8 byte and by default, it holds 0.0d<\/li>\n<\/ul>\n\n\n\n<p>There are also some non-primitive data types like arrays, classes such as String etc.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conditional-statements\"><strong>Conditional Statements<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"if-else\"><strong>if-else<\/strong><\/h3>\n\n\n\n<p>The if-else statement consists of 2 keywords, if and else. This is a way where there are 2 paths possible depending upon a condition. I.e., 'if' condition manipulates to true then it gets executed otherwise code 'else' will execute. You can multiple \u2018else if\u2019 followed by else if there are more possible paths. Also, nested if and else are possible.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class IfElseDemo  {\n\tpublic static void main (String&#091;] args) {\n\t\tint a=5,b=6;\n\t\tif(a+b==11)\n\t\t    System.out.println(\"equal\");\n\t\telse\n\t\t    System.out.println(\"not equal\");\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">true<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"switch\"><strong>switch<\/strong><\/h3>\n\n\n\n<p>It is an elegant way to replace multiple else-if<\/p>\n\n\n\n<p><strong>Syntax<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>switch(expression)\n{\n    case val: ... ; \n              break;\n    case val: ... ; \n              break;\n    case val: ... ; \n              break;\n    default: ...;\n}<\/code><\/pre>\n\n\n\n<p>Here depending upon the answer evaluated by the condition, case code gets executed. Every case must be followed by break unless it is required not to as per logic. Otherwise, all cases will start executing from the matched case till either break is encountered or all cases get exhausted. <\/p>\n\n\n\n<p>\u2018default\u2019 is optional and holds the code which should be executed if no catches get matched.<\/p>\n\n\n\n<p>\u2018val\u2019 can be integer, char or String in java.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class SwitchDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tString day=\"sun\";\n\t\tswitch(day)\n\t\t{\n\t\t    case \"mon\": System.out.println(\"Today is monday\");\n\t\t                   break;\n\t\t    case \"tues\": System.out.println(\"Today is tuesday\");\n\t\t                   break;\n\t\t    case \"wed\": System.out.println(\"Today is wednesday\");\n\t\t                   break;\n\t\t    case \"thurs\": System.out.println(\"Today is thursday\");\n\t\t                   break;\n\t\t    case \"fri\": System.out.println(\"Today is friday\");\n\t\t                   break;\n\t\t    case \"sat\": System.out.println(\"Today is saturday\");\n\t\t                   break;\n\t\t    case \"sun\": System.out.println(\"Today is sunday\");\n\t\t                   break;\n\t\t    default : System.out.println(\"day is invalid!\");\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Today is sunday<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"loops\"><strong>Loops<\/strong><\/h2>\n\n\n\n<p>Three major loops are \u2018for\u2019, \u2018while\u2019, and \u2018do while\u2019<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"for-loop-java\"><strong>for loop java:<\/strong><\/h3>\n\n\n\n<p>It is best to use when we know the specified number of times the code should execute.<\/p>\n\n\n\n<p><strong>Syntax<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for( initialization; termination; updation){\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>'initialization' is used to initialize the variable, which is being used for iteration.<\/li>\n\n\n\n<li>'termination' - comprises conditions which determine till when iteration will continue.<\/li>\n\n\n\n<li>'updation' - how our variable will get updated.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ForDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tfor(int i=0;i&lt;5;i++)\n\t\t    System.out.println(\"current value of i : \"+i);\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">current value of i : 0\ncurrent value of i : 1\ncurrent value of i : 2\ncurrent value of i : 3\ncurrent value of i : 4<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"while-loop-java\"><strong>while loop java<\/strong><\/h3>\n\n\n\n<p>It is best to use when we know the specified expression depending on whose value the code should execute.<\/p>\n\n\n\n<p><strong>Syntax<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while( expression ){\n}\n<\/code><\/pre>\n\n\n\n<p>\u2018expression\u2019 is used to dictate the condition who is responsible for loop continuation.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class WhileDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tint i=0;\n\t\twhile(i&lt;5){\n\t\t    System.out.println(\"current value of i : \"+i);\n\t\t    i++;\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">current value of i : 0\ncurrent value of i : 1\ncurrent value of i : 2\ncurrent value of i : 3\ncurrent value of i : 4<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"do-while-loop-java\"><strong>do-while loop java :<\/strong><\/h3>\n\n\n\n<p>It is best to use when we know that at least code must execute once irrespective of the condition.<\/p>\n\n\n\n<p><strong>Syntax<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>do{\n}while( expression );\n<\/code><\/pre>\n\n\n\n<p>'expression' is used to dictate the condition who is responsible for loop continuation.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class DoWhileDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tint i=0;\n\t\tdo{\n\t\t    System.out.println(\"current value of i : \"+i);\n\t\t    i++;\n\t\t}while(i&lt;5);\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">current value of i : 0\ncurrent value of i : 1\ncurrent value of i : 2\ncurrent value of i : 3\ncurrent value of i : 4<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"branching-statements-in-java\"><strong>Branching Statements in Java<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"break\"><strong>break<\/strong><\/h3>\n\n\n\n<p>It is a keyword that basically terminates the current loop and moves execution out of the loop<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for(.........){\nbreak;\n} ==&gt;execution comes here when the break is encountered<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class BreakDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tint i=0;\n\t\twhile(i&lt;5){\n\t\t    System.out.println(\"current value of i : \"+i);\n\t\t    i++;\n\t\t    if(i==3)\n\t\t        break;\n\t\t}\n\t\t\n\t\tSystem.out.println(\"Out of loop!\");\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">current value of i : 0\ncurrent value of i : 1\ncurrent value of i : 2\nOut of loop!<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"continue\"><strong>continue<\/strong><\/h3>\n\n\n\n<p>It is a keyword that basically terminates the current iteration and moves execution to the update part of the loop. In \u2018while\u2019 and \u2018do-while\u2019, when continue is encountered, it will ignore the rest of the code<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for(.. ; .... ; ...)==&gt;execution comes here when break is encountered\n{\ncontinue;\n} \n<\/code><\/pre>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ContinueDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tfor(int i=0;i&lt;5;i++){\n\t   \n\t\t    if(i==3)\n\t\t        continue;\n\t\t    System.out.println(\"current value of i : \"+i);\n\t\t   \n\t\t}\n\t\t\n\t\tSystem.out.println(\"Out of loop!\");\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">current value of i : 0\ncurrent value of i : 1\ncurrent value of i : 2\ncurrent value of i : 4\nOut of loop!<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"return\"><strong>return<\/strong><\/h3>\n\n\n\n<p>It returns from its block of code i.e. if it is inside a function, it will exit from it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>main(.........){\nreturn;\n} \n==&gt;exists from the program\n<\/code><\/pre>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ReturnDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tfor(int i=0;i&lt;5;i++){\n\t   \n\t\t    if(i==3)\n\t\t        return;\n\t\t    System.out.println(\"current value of i : \"+i);\n\t\t   \n\t\t}\n\t\t\n\t\tSystem.out.println(\"Out of loop!\");\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">current value of i : 0\ncurrent value of i : 1\ncurrent value of i : 2<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"comment\"><strong>Comment<\/strong><\/h2>\n\n\n\n<p>Comments are used to give a brief description of what is the logic behind code. They are just ignored by the compiler at the time of execution.<\/p>\n\n\n\n<p>In java, we have sing line and multi-line comments:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ - single line\n\nand \n\n\/*\n\u2026.\n\u2026.&nbsp;\n*\/ - multi line\n\n <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"java-class\"><strong>Java Class<\/strong><\/h2>\n\n\n\n<p>It is a blueprint of a real-life entity and consists of the data and methods. Basically, it is the implementation of Encapsulation which is one of the OOPs pillars.<\/p>\n\n\n\n<p>Keyword class is used to declare the class in java. As per naming convention, the class name follows that the first letter of every word should be in uppercase. Also, all code must be in some class and the single document can have multiple classes but only 1 public class<\/p>\n\n\n\n<p><strong>Example <\/strong>:&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Container{\n   \n\/\/data members \n     int weight;\n    String color;\n    double price;\n    \n\/\/methods\n    void setWeight(int w){\n        weight=w;\n    }\n    void setColor(int c){\n        color=c;\n    }\n    void setPrice(int p){\n        price=p;\n    }\n    void print(){\n        System.out.println(weight+\" \"+color+\" \"+price);\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"object\"><strong>Object<\/strong><\/h2>\n\n\n\n<p>It is basically a physical entity of class, a class's instance. The new keyword is used to create objects and allocate memory in Heap. When we create an object, it calls for the constructor of a class.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Container c1=new Container();\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"constructor-in-java\"><strong>Constructor in Java<\/strong><\/h2>\n\n\n\n<p>The <a href=\"https:\/\/www.mygreatlearning.com\/blog\/constructor-in-java\/\">constructor<\/a> is a special method that is used to allocate memory and initialize objects. It doesn't have any return type and its name is same as of its class name. The compiler implicitly provides a default constructor to allocate the memory if no constructor is explicitly defined.<\/p>\n\n\n\n<p>Constructor having parameters are categorised as parameterised constructor. When new is encountered, it calls for the constructor. Parameters passed at the time of the creation of the object determines which constructor should be called.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Container{\n    int weight;\n    String color;\n    double price;\n    \n    \/\/parameterized constructor\n    Container(int w,String c,double p)\n    {\n        weight=w;\n        color=c;\n        price=p;\n        System.out.println(\"I am a parameterized constructor\");\n    }\n    \n    \/\/default constructor\n    Container()\n    {\n        System.out.println(\"I am a default constructor\");\n    }\n    \n    void print(){\n        System.out.println(weight+\" \"+color+\" \"+price);\n    }\n}\npublic class ConstructorDemo {\n\tpublic static void main (String&#091;] args) {\n\t    Container c1=new Container();\n\t    Container c2=new Container(10,\"red\",567.85);\n\t    c1.print();\n\t    c2.print();\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">I am a default constructor\nI am a parameterized constructor\n0 null 0.0\n10 red 567.85 <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"super\"><strong>Super&nbsp;<\/strong><\/h2>\n\n\n\n<p>\u2018Super\u2019 is generally associated with parent class. It extends keyword used for an inheritance that will establish a child-parent relationship. You can call parent's method, data members and constructor using super. While calling the parent's constructor using super, it should be the 1st line in the code block<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"this\"><strong>This<\/strong><\/h2>\n\n\n\n<p>\u2018This\u2019 is generally associated with the current class. You can call current class method, data members and constructor using this. While calling the current class constructor using this, it should be the 1st line in the code block.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/parent class\nclass Hostel{\n    String address;\n    String name;\n    \n    \/\/parameterized constructor to initialize add and name\n    Hostel(String address,String name){\n        \/*\n            using this to point to the Hotel's address and name\n            if there is no this, the parameter will assign values to local var and the class var will still have default values.\n        *\/\n        this.address=address; \n        this.name=name;         \n    }\n    \n    \/\/parameterized constructor to initialize just name\n    Hostel(String name){\n        this.name=name;\n    }\n    \n    \/\/method to print address\n    void printAddress(){\n        System.out.println(\"address : \"+address);\n    }\n    \n}\n\n\/\/child class\nclass Room extends Hostel{\n    int number;\n    String name;\n\n    \/\/parameterized constructor to initialize address, name and number\n    Room(String address,String name,int number){\n        super(name); \/\/calling parent's constructor\n        this.address=address;\n        this.name=name;\n        this.number=number;\n    }\n    \n    \/\/method to print all details of room\n    void printRoomDetails(){\n        System.out.println(\"name : \"+name);\n        super.printAddress();\n        System.out.println(\"room no. : \"+number);\n    }\n}\n\nclass Demo {\n\tpublic static void main (String&#091;] args) {\n\t    Room r1=new Room(\"12th street,NY\",\"CS Block \",43);\n\t    r1.printRoomDetails();\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">name : CS Block&nbsp;\naddress : 12th street,NY\nroom no. : 43 <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"static-keyword-in-java\"><strong>Static Keyword in Java<\/strong><\/h2>\n\n\n\n<p><strong>Keyword<\/strong><\/p>\n\n\n\n<p>Keywords are otherwise known as reserved words, which represents predefined actions. Keywords are mainly used for some internal process. We cannot use keywords as objects and variable name as well. In such a case, if we use keywords as objects or variable name, we will get a compile-time error. There are many types of keywords. We will see about static keywords in this blog.<\/p>\n\n\n\n<p><strong>Static keyword<\/strong><\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;A static keyword is one of the types of keywords. A static keyword represents a member that belongs to a particular type itself, not to an instance of that type.&nbsp;<\/p>\n\n\n\n<p>This means a single instance is created for the static member and used for all instance of the class.<\/p>\n\n\n\n<p>A keyword can be created for methods, variables, blocks and also for nested class.<\/p>\n\n\n\n<p><strong>Static variable<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;&nbsp;&nbsp;&nbsp;If any variable is used as static, then the variable is known as a static variable.<\/li>\n\n\n\n<li>If any variable is used to indicate an object\u2019s common property, then the variable is a static variable.<\/li>\n\n\n\n<li>For example: country for population, city name for customers, etc.<\/li>\n\n\n\n<li>It is mainly used to manage memory.<\/li>\n\n\n\n<li>It is used when the variable is independent and common for all objects.<\/li>\n<\/ul>\n\n\n\n<p><strong>Points to note<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The class contains static variables; hence, using the class name it can be accessed does not require a reference of the object.<\/li>\n\n\n\n<li>At the class level, static variable can be declared.<\/li>\n\n\n\n<li>It does not need any object initiation to access.<\/li>\n<\/ul>\n\n\n\n<p><strong>Syntax<\/strong><\/p>\n\n\n\n<p>static data_type variable_name;<\/p>\n\n\n\n<p><strong>Example of static variable keyword<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class numbers\n{\n   static int count=0;\n   public void increment()\n   {\n       count++;\n   }\n   public static void main(String args&#091;])\n   {\n       numbers obj1=new numbers();\n       numbers obj2=new numbers();\n       obj1.increment();\n       obj2.increment();\n       System.out.println(\"Obj1: count is=\"+obj1.count);\n       System.out.println(\"Obj2: count is=\"+obj2.count);\n   }\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p>Obj1: count is=2<\/p>\n\n\n\n<p>Obj2: count is=2<\/p>\n\n\n\n<p>As shown in the above illustration, both objects contain the same variable objects.<\/p>\n\n\n\n<p><strong>Static method<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We can use a static keyword for methods to use such method as static method.<\/li>\n\n\n\n<li>We can use the static method for the class, not for objects in a class.<\/li>\n\n\n\n<li>A static method can use a static data member and can change the value of a static data member.<\/li>\n\n\n\n<li>Without creating an instance of the class, we can create a static method<\/li>\n\n\n\n<li>The major advantage of the static method is it does not require an object.<\/li>\n<\/ul>\n\n\n\n<p>Points to note:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We cannot override the static method because it is compiled at runtime.<\/li>\n\n\n\n<li>We cannot make the abstract method static.<\/li>\n\n\n\n<li>It does not use superkeys.<\/li>\n\n\n\n<li>The static method needs the reference of objects to access instance variable and methods directly.<\/li>\n\n\n\n<li>It can access all static variable and also other static methods as well.<\/li>\n<\/ul>\n\n\n\n<p><strong>Syntax<\/strong><\/p>\n\n\n\n<p>&lt;<em>class-name&gt;.&lt;method-name&gt;<\/em><\/p>\n\n\n\n<p><strong>Example of static method<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class mall{\n   public static void main(String args&#091;]){\n     customer c1 = new customer();\n     c1.showData();\n     customer c2 = new customer();\n     c2.showData();\n     \/\/customer.b++;\n     \/\/c1.showData();\n  }\n}\n \nclass Customer {\nint a; \/\/initialized to zero\nstatic int b; \/\/initialized to zero only when class is loaded not for each object created.\n \n  Customer(){\n   \/\/Constructor incrementing static variable b\n   b++;\n  }\n \n   public void showData(){\n      System.out.println(\"Value of a = \"+a);\n      System.out.println(\"Value of b = \"+b);\n   }\n\/\/public static void increment(){\n\/\/a++;\n\/\/}\n \n}\n<\/code><\/pre>\n\n\n\n<p><strong>Static block<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To initialize a static data member static block is used.<\/li>\n\n\n\n<li>At the time of class loading, it is executed before the main method.<\/li>\n\n\n\n<li>A static block is nothing but a block of statement inside the class.<\/li>\n\n\n\n<li>If the initialization of the static block is an error, it requires exception handling.<\/li>\n<\/ul>\n\n\n\n<p>Points to remember:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A single class may contain many static blocks.<\/li>\n\n\n\n<li>Static variable and static block should maintain the same order as they are present in class. &nbsp;<\/li>\n<\/ul>\n\n\n\n<p><strong>&nbsp;Example of a static block<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class number {\n static int i;\n static int j;\n\/\/ static block\n static {\n    i = 50;\n    j = 100;\n }\n public static void main(String args&#091;]) {\n \n  \n  system.out.println(\u201cstatic block initialized\u201d);\n  System.out.println(\"Value of i = \" + i);\n  System.out.println(\"Value of j = \" + j);\n \n \t}\n}\n<\/code><\/pre>\n\n\n\n<p><strong>Static class<\/strong><\/p>\n\n\n\n<p>If a class is a nested class only then, we can convert it into a static class. It does not require an outer class reference. Hence non-static member of the outer class cannot be accessed by a static class.<\/p>\n\n\n\n<p>Points to note:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Static class can be accessed by reference to an object.<\/li>\n\n\n\n<li>We cannot use the top-level class as a static class; hence only nested class can be converted into static.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example of static class<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Java program to demonstrate how to\n\/\/ implement static classes in java program\n \nclass OuterClass {\n    private static String msg = \"Great Learning\";\n  \n    \/\/ Static nested class\n    public static class NestedClass {\n  \n        \/\/ Only static members of Outer class\n        \/\/ is directly accessible in nested\n        \/\/ static class\n        public void print()\n        {\n  \n            \/\/ Try making 'message' a non-static\n            \/\/ variable, there will be compiler error\n            System.out.println(\n                \"Message from nested static class: \"\n                + msg);\n        }\n    }\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"inheritance-in-java\"><strong>Inheritance in Java<\/strong><\/h2>\n\n\n\n<p>One of the very important pillars of OOPs, it facilitates the reusability of code as a child can inherit from the parent. Child can also implement additional data members or methods of its own. This is a IS-A relationship between child and parent.<\/p>\n\n\n\n<p>Example: We did this in the above example where Room(child) inherits from Hostel(parent).<\/p>\n\n\n\n<p>Java doesn't suppose classic multiple inheritances due to ambiguity that it may cause. But you can have multiple inheritance via interfaces.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-overloading-in-java\"><strong>Method Overloading in Java<\/strong><\/h2>\n\n\n\n<p>This basically is a compile-time polymorphism. There can be multiple methods with the same name but different parameters list which may differ in types or number of arguments<\/p>\n\n\n\n<p>\u2018Method\u2019 cannot be overloaded by just changing the return type of methods.It provides an ease to the programmer and helps in the understanding of code<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class OverloadingDemo {\n    \n    int multiply(int a,int b){\n        return a*b;\n    }\n    \n    \/\/overloaded multiply with 3 parameters\n    int multiply(int a,int b,int c){\n        return a*b*c;\n    }\n    \n    \/\/overloaded multiply with 2 parameters of different type\n    double multiply(int a,double b){\n        return a*b;\n    }\n    \n\tpublic static void main (String&#091;] args) {\n\t    OverloadingDemo ob=new OverloadingDemo();\n\t\tSystem.out.println(ob.multiply(3,5));\n\t\tSystem.out.println(ob.multiply(3,5,3));\n\t\tSystem.out.println(ob.multiply(3,5.5));\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">15\n45\n16.5<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"method-overriding-in-java\"><strong>Method Overriding in Java<\/strong><\/h2>\n\n\n\n<p>This is runtime polymorphism. Here if a child class wants to override parent's method i.e., wants to give its own implementation then it can do that by having exactly the same signature with its implementation.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Parent{\n    void hobbies()\n    {\n        System.out.println(\"Reading Books\");\n    }\n}\n\nclass Child extends Parent{\n    \n    \/\/same method as of parent but different implementation\n    void hobbies()\n    {\n        System.out.println(\"Travelling\");\n    }\n}\n\n\nclass OverridingDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tChild ob=new Child();\n\t\tob.hobbies();\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Travelling <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"abstract-class-in-java\"><strong>Abstract class in Java<\/strong><\/h2>\n\n\n\n<p>If a method doesn't have its implementation then it is known as \u2018abstract\u2019 method. A class having 1 or more abstract methods is known as an abstract class. It actually implements OOPs abstraction to a certain extent<\/p>\n\n\n\n<p>Abstract keyword is used for declaring abstract class. An abstract class can have abstract and non-abstract methods and it can't be instantiated.<\/p>\n\n\n\n<p>Rather it has to be extended and abstract methods have to be given their implementation.<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract class Keyboard{\n    abstract void working();\n    void name(){\n        System.out.println(\"This is Keyboard component\");\n    }\n}\n\nclass Hp extends Keyboard{\n    \/\/implementing abstract method\n    void working(){\n        System.out.println(\"This is hp Keyboard\");\n    }\n    \n}\npublic class AbstractClassDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tHp ob=new Hp();\n\t\tob.working();\n\t\tob.name();\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">This is hp Keyboard\nThis is Keyboard component<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"interface-in-java\"><strong><a href=\"https:\/\/www.mygreatlearning.com\/blog\/interface-in-java\/\">Interface in Java<\/a><\/strong><\/h2>\n\n\n\n<p>It enforces 100% abstraction. Here all methods are abstract by default and thus it is not necessary to write abstract keyword while declaring them<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>interface Toy{\n    void start();\n    void run();\n}\n\nclass Car implements Toy{\n    public void start(){\n        System.out.println(\"car started\");\n    }\n    \n    public void run(){\n        System.out.println(\"car running\");\n    }\n}\nclass InterfaceDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tCar ob=new Car();\n\t\tob.start();\n\t\tob.run();\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">car started\ncar running\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Compiler implicitly adds a public abstract in front of every method of the interface<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>T:&gt;javap Toy\nCompiled from \"GFG.java\"\ninterface Toy{\n    public abstract void start();\n    public abstract void run();\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>implements keyword is used by the class that wants to use it and has to give a definition for every method<\/li>\n\n\n\n<li>While implementing interface methods, specifying public access modifiers is must<\/li>\n\n\n\n<li>A class can implement multiple interfaces which enable a sort of multiple inheritances<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"exception-handling-in-java\"><strong>Exception Handling in Java<\/strong><\/h2>\n\n\n\n<p>An exception is an abnormal condition that may happen at runtime and disturb the normal flow of the program. So we can handle exceptions in order to ensure our code gets executed normally<\/p>\n\n\n\n<p>There are 2 major category of exception&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Checked\n<ul class=\"wp-block-list\">\n<li>Those exception that are checked at compile-time comprises of checked exception<\/li>\n\n\n\n<li>They are child classes of Exception except RuntimeException<\/li>\n\n\n\n<li>Example: IOException, ClassNotFoundException etc.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Unchecked\n<ul class=\"wp-block-list\">\n<li>Those exception that are checked at runtime comprises of unchecked exception<\/li>\n\n\n\n<li>They are child classes of RuntimeException.<\/li>\n\n\n\n<li>Example: ArithmeticException, NullPointerException etc. <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Basic syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try{\n\n}catch(Exception e){\n\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>There are 5 keywords in Java exception handling:\n<ul class=\"wp-block-list\">\n<li>try<\/li>\n\n\n\n<li>catch<\/li>\n\n\n\n<li>finally<\/li>\n\n\n\n<li>throw<\/li>\n\n\n\n<li>throws<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u2018try\u2019 <\/strong>block contains the code that might throw an exception. Don't write anything extra in try as statements after the exception will not get executed if the exception occurred<\/li>\n\n\n\n<li><strong>\u2018catch\u2019 <\/strong>block is used to catch the exception thrown by statements in the try block. It must follow try else it will give a compile-time error.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ExceptionDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tint a=10;\n\t\tfor(int i=3;i&gt;=0;i--)\n\t\t   try{\n\t\t     System.out.println(a\/i);  \n\t\t   }catch(ArithmeticException e){\n\t\t       System.out.println(e);\n\t\t   }\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">3\n5\n10\njava.lang.ArithmeticException: \/ by zero <\/pre>\n\n\n\n<p>There can be multiple catch, which should be placed from child to parent in order to get the desired output. <strong>finally <\/strong>block contains code that must be executed no matter if an exception is thrown or not. finally generally contains code of file release, memory cleaning etc.<\/p>\n\n\n\n<p><strong>Exception:&nbsp;<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ExceptionDemo {\n\tstatic void canVote(int age){\n\t\tif(age&lt;18)\n            try{\n                throw new Exception();\n            }catch(Exception e){\n                System.out.println(\"you are not an adult!\");\n            }\n\t\telse\n\t\t   System.out.println(\"you can vote!\");\n\t}\n\tpublic static void main (String&#091;] args) {\n\t\tcanVote(20);\n\t\tcanVote(10);\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">5\nI am finally<\/pre>\n\n\n\n<p><strong>throw <\/strong>keyword is used to explicitly throw an exception which normally doesn't throw an exception.<\/p>\n\n\n\n<p><strong>Exception:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ExceptionDemo {\n\tstatic void canVote(int age){\n\t\tif(age&lt;18)\n            try{\n                throw new Exception();\n            }catch(Exception e){\n                System.out.println(\"you are not an adult!\");\n            }\n\t\telse\n\t\t   System.out.println(\"you can vote!\");\n\t}\n\tpublic static void main (String&#091;] args) {\n\t\tcanVote(20);\n\t\tcanVote(10);\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">you can vote!\nyou are not an adult!<\/pre>\n\n\n\n<p><strong>throws<\/strong> basically say what sort of exception the code can throw and relies on the caller to handle it<\/p>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class ExceptionDemo {\n\tstatic void func(int a) throws Exception{\n\t\t   System.out.println(10\/a);  \n\t}\n\tpublic static void main (String&#091;] args) {\n\t\ttry{\n\t\t    func(10);\n\t\t    func(0);\n\t\t}catch(Exception e){\n\t\t   System.out.println(\"can't divide by zero\");\n\t\t}\n\t\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1\ncan't divide by zero <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"string\"><strong>String<\/strong><\/h2>\n\n\n\n<p>A string is a sequence of characters. It's a class in java and there are 2 ways to create a string:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>String str = \"hello\";<\/li>\n\n\n\n<li>String str = new String(\"hello\");<\/li>\n<\/ul>\n\n\n\n<p>We have special memory termed as string constant pool inside heap and,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the first way, a copy is created in heap and in SCP too if it was not already there<\/li>\n\n\n\n<li>In the second way, copy is created in heap only<\/li>\n<\/ul>\n\n\n\n<p>String can also be created using char array<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>char[] ch={'h','e','l','l','o'};<\/li>\n\n\n\n<li>String str=new String(ch);<\/li>\n<\/ul>\n\n\n\n<p>String is immutable that means once created it cannot be manipulated<\/p>\n\n\n\n<p>There are three ways to check for equality in String:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>== : checks for same reference<\/li>\n\n\n\n<li>.equals() : checks for same content<\/li>\n\n\n\n<li>.compareTo() : compares content lexicographically\n<ul class=\"wp-block-list\">\n<li>return +ve num : str1&gt;str2<\/li>\n\n\n\n<li>return -ve num : str1&lt;str2<\/li>\n\n\n\n<li>return 0 : str1==str2<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Example<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class StringDemo {\n\tpublic static void main (String&#091;] args) {\n\t\tString s1=new String(\"cat\");\n\t\tString s2=\"cat\";\n\t\tString s3=\"cat\";\n\t\tSystem.out.println(s1==s2);\n\t\tSystem.out.println(s2==s3);\n\t\tSystem.out.println(s1==s3);\n\t\tSystem.out.println(s1.equals(s3));\n\t\tSystem.out.println(s1.compareTo(s2));\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>false\ntrue\nfalse\ntrue\n0\n<\/code><\/pre>\n\n\n\n<p>String has many methods that help in working with strings. Some of them are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>length()<\/li>\n\n\n\n<li>toUpperCase()<\/li>\n\n\n\n<li>toLowerCase()<\/li>\n\n\n\n<li>contains()<\/li>\n\n\n\n<li>indexOf()<\/li>\n\n\n\n<li>substring()<\/li>\n\n\n\n<li>split()<\/li>\n\n\n\n<li>replace()<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>public class StringDemo {\n\tpublic static void main (String&#091;] args) {\n\t    String str=\"Today is monday.\";\n\t\tSystem.out.println(str.length());\n\t\tSystem.out.println(str.toLowerCase());\n\t\tSystem.out.println(str.toUpperCase());\n\t\tSystem.out.println(str.contains(\"is monday\"));\n\t\tSystem.out.println(str.indexOf(\"monday\"));\n\t\tSystem.out.println(str.substring(4,8));\n\t\tSystem.out.println(str.replace(\"monday\",\"tuesday\"));\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong> Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>16\ntoday is monday.\nTODAY IS MONDAY.\ntrue\n9\ny is\nToday is tuesday.<\/code><\/pre>\n\n\n\n<p>For mutable String, java does have 2 more classes<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>StringBuilder (non synchronized i.e, not thread-safe)<\/li>\n\n\n\n<li>StringBuffer (synchronized i.e, thread-safe)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"packages-in-java\"><strong>Packages in Java<\/strong><\/h2>\n\n\n\n<p>A package in Java is used to group or organize a collection of similar classes and interfaces. It provides access protection and namespace management.&nbsp;<\/p>\n\n\n\n<p>In simpler terms, it is just like a folder or directory on your system. It helps to avoid name conflicts and write better code for easier maintainability.&nbsp;<\/p>\n\n\n\n<p>Java provides you with a wide range of packages in a class library. This library is called the Application Program Interface (API).<\/p>\n\n\n\n<p>There are two types of Packages in Java:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Built-in Packages: <\/strong>These packages contain numerous classes that are part of Java API. Some widely used packages are:\n<ol class=\"wp-block-list\">\n<li><strong>java.lang:<\/strong> Language support classes like mathematical operations.<\/li>\n\n\n\n<li><strong>java.io: <\/strong>Input and Output operations.<\/li>\n\n\n\n<li><strong>java.util: <\/strong>Utility classes like data structures, date\/time operations, etc.<\/li>\n\n\n\n<li><strong>java.applet: <\/strong>Used to create applets.<\/li>\n\n\n\n<li><strong>java.awt: <\/strong>It consists of classes that are used to implement GUI components like menus, buttons, etc.<\/li>\n\n\n\n<li><strong>java.net: <\/strong>Networking operations.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<p>There are other numerous built-in packages in Java. You can use them as per your program choice.<br><br><strong>User-defined Packages:<\/strong> The user, i.e., you, can define these packages. We use the \u201cpackage\u201d keyword to create a package. Let\u2019s see a simple example to understand the working of packages.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/Save as PackageDemo.java \npackage myfirstpack; \npublic class PackageDemo {  \n public static void main(String args&#x5B;]) {  \n    System.out.println(&quot;This is my package.&quot;);  \n   }  \n} \n\n<\/pre><\/div>\n\n\n<p>Now, open cmd and type the following command to compile:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\njavac -d . PackageDemo.java\n\n<\/pre><\/div>\n\n\n<p>The above command forces the compiler to create the \u201cmyfirstpack\u201d package. The \u201c-d\u201d keyword describes the destination for saving the generated class file. You can use dot (.) to keep the package within the same directory.<\/p>\n\n\n\n<p>Next, type the following command to run your package:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\njava myfirstpack.PackageDemo\n\n<\/pre><\/div>\n\n\n<p><strong>Output: <\/strong>This is my package.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"access-modifiers-in-java\"><strong>Access Modifiers in Java<\/strong><\/h2>\n\n\n\n<p>An access modifier determines the accessibility or scope of a class, constructor, fields, variables, or methods. There are four types of access modifiers in Java:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Public<\/li>\n\n\n\n<li>Protected<\/li>\n\n\n\n<li>Default - There is no keyword necessary<\/li>\n\n\n\n<li>Private<\/li>\n<\/ol>\n\n\n\n<p>Let\u2019s look at a table on how access modifiers work with classes and packages.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Access Modifier<\/strong><\/td><td><strong>Same Class<\/strong><\/td><td><strong>Same Package<\/strong><\/td><td><strong>Outside Package by Subclass Only<\/strong><\/td><td><strong>Outside Package<\/strong><\/td><\/tr><tr><td><strong>Public<\/strong><\/td><td>Yes<\/td><td>Yes<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><tr><td><strong>Protected<\/strong><\/td><td>Yes<\/td><td>Yes<\/td><td>Yes<\/td><td>No<\/td><\/tr><tr><td><strong>Default<\/strong><\/td><td>Yes<\/td><td>Yes<\/td><td>No<\/td><td>No<\/td><\/tr><tr><td><strong>Private<\/strong><\/td><td>Yes<\/td><td>No<\/td><td>No<\/td><td>No<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Public Access Modifier<\/strong><\/li>\n<\/ol>\n\n\n\n<p>This modifier has the most comprehensive scope among the other access modifiers that are accessible anywhere in the program.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>Write the following code in the A.java file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npackage firstpack; \npublic class A {  \n    public void msg_display() {\n        System.out.println(&quot;Great Learning&quot;);\n    }  \n}\nWrite the following code in the B.java file.\npackage secondpack;  \nimport firstpack.*;  \nclass B {  \n    public static void main(String args&#x5B;]) {  \n        A ob = new A();  \n        ob.msg_display();  \n    }  \n} \nNow, run the following commands one after another to produce the output.\njavac -d . A.java\njavac -d . B.java\njava secondpack.B\n\n<\/pre><\/div>\n\n\n<p><strong>Output: <\/strong>Great Learning<\/p>\n\n\n\n<p><strong>2.  Protected Access Modifier<\/strong><\/p>\n\n\n\n<p>These access modifiers are accessible within the same package or subclasses in different packages, which can be applied to data members, methods, and constructors.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>Write the following code in the A.java file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npackage firstpack; \npublic class A {  \n    protected void msg_display() {\n        System.out.println(&quot;Great Learning&quot;);\n    }  \n}\nWrite the following code in the B.java file.\npackage secondpack;  \nimport firstpack.*;  \n  \nclass B extends A {  \n    public static void main(String args&#x5B;]) {  \n        B ob = new B();  \n        ob.msg_display();  \n    }  \n} \n\n<\/pre><\/div>\n\n\n<p>Now, run the following commands one after another to produce the output.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>javac -d . A.java<\/li>\n\n\n\n<li>javac -d . B.java<\/li>\n\n\n\n<li>java secondpack.B<\/li>\n<\/ol>\n\n\n\n<p><strong>Output: <\/strong>Great Learning<\/p>\n\n\n\n<p><strong>3. Default Access Modifier<\/strong><\/p>\n\n\n\n<p>If no modifier is defined to a class, method, or data member, it takes the <strong>default<\/strong> access modifier. These modifiers are accessible only within the same package and not from outside the package.&nbsp;<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>Write the following code in the A.java file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npackage firstpack; \nclass A {  \n    void msg_display() {\n        System.out.println(&quot;Great Learning&quot;);\n    }  \n}\n\n<\/pre><\/div>\n\n\n<p>Write the following code in the B.java file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npackage secondpack;  \nimport firstpack.*;  \nclass B {  \n    public static void main(String args&#x5B;]) {  \n        A ob = new A();  \/\/Compile Time Error\n        ob.msg_display();  \/\/Compile Time Error\n    }  \n} \n\n<\/pre><\/div>\n\n\n<p>Now, run the following commands one after another to produce the output.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>javac -d . A.java<\/li>\n\n\n\n<li>javac -d . B.java<\/li>\n<\/ol>\n\n\n\n<p>You will get compile-time errors as the scope of class A and method msg_display() is set to default, which cannot be accessed from outside the package.<\/p>\n\n\n\n<p><strong>4. Private Access Modifier<\/strong><\/p>\n\n\n\n<p>These modifiers are accessible only within the same class where they are declared. Any other class of the same package cannot access these members.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>We will create two classes, A and B, within the same \u201cfirstpack\u201d package. Next, specify the scope of a method in class A as private and try to access this method from class B. Now, see the output produced.<\/p>\n\n\n\n<p>Write the following code in the A.java file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npackage firstpack; \nclass A { \n    private void msg_display() { \n        System.out.println(&quot;Great Learning&quot;); \n    } \n} \n  \nclass B { \n    public static void main(String ags&#x5B;]) { \n        A ob = new A(); \n        \/\/ Trying to access private method &quot;msg_display()&quot; of class B\n        ob.msg_display(); \n    } \n}\n\n<\/pre><\/div>\n\n\n<p>Now, run the following command to check the output:<\/p>\n\n\n\n<p>javac -d . A.java<\/p>\n\n\n\n<p><strong>Output:&nbsp;<\/strong><\/p>\n\n\n\n<p>error: msg_display() has private access in A<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ob.msg_display();<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"linked-lists\">Linked Lists <\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-are-linked-lists\"><strong>What are Linked Lists?<\/strong><\/h3>\n\n\n\n<p>A Linked list is a collection of nodes attached linearly. You can imagine a train; for example, there are different train compartments, and all of them are connected. Similarly, in a linked list, various nodes consist of the next node\u2019s data and memory location. Due to the presence of memory location, the nodes are said to be attached.&nbsp;<\/p>\n\n\n\n<p>Linked lists are linear data structures. They are used when we need to insert or delete data at the starting, ending or middle of the linked list. The process of adding and deleting data is simple in a linked list. We need not specify the size of the linked list at the time of creating it. The nodes are created anywhere there is free memory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-do-linked-lists-function-in-java\"><strong>How do Linked Lists function in Java?<\/strong><\/h3>\n\n\n\n<p>In C language, we use pointers to point to the memory location of the next node. The nodes are not necessarily present side by side. We can access them through the address pointers. Thus, the nodes are connected to one another. Jumping from one node to another node using memory locations is known as Pointer hopping.<\/p>\n\n\n\n<p>For instance, consider that the first node, known as 'Head', would be present in the address, let's say 50001, and my next node is at memory location 100010. This address is stored in the node along with the data. Thus we can access the second node using its address 100010.<\/p>\n\n\n\n<p>In Java, however, there are no pointers. Thus we use references to refer to the address of the next node. Here, Jumping from one node to another using memory locations is known as link-hopping.<\/p>\n\n\n\n<p>But we need not declare any variable or a reference for now because the linked list is a part of the collection framework in the Java.util package.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"creation-of-linked-list-in-java\"><strong>Creation of Linked List in Java:<\/strong><\/h3>\n\n\n\n<p>To create a linked list in Java, as stated earlier, we use the Java.util package and declare an object for the Linked List class. Then we can keep on adding and removing elements as the methods are built-in with the class LinkedList.&nbsp;<\/p>\n\n\n\n<p><strong>Example<\/strong>: Creating a linked list in java for storing prime numbers until 10.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*;\n public class PrimeNumbers {\n \n    public static void main(String args&#091;])\n    {\n        \/\/ object of the class linked list is created\n        LinkedList&lt;Integer&gt; lk = new LinkedList&lt;Integer&gt;();\n       \/\/ Adding prime numbers to the linked list\n        lk.add(2);\n        lk.add(3);\n        lk.add(5);\n        lk.add(7);\n \n        System.out.println(lk);\n   }\n}\n<\/code><\/pre>\n\n\n\n<p><strong>OUTPUT<\/strong>:<\/p>\n\n\n\n<p>[2, 3, 5, 7]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"adding-elements-to-linked-list\"><strong>Adding Elements to Linked List:<\/strong><\/h3>\n\n\n\n<p>We can add different elements at the start, end and middle of the list. For example, I want to prepare a linked list for students in a class based on their initials. I add them to the list using add() method. If I need to add new students, I specify the specific index in the list and their name and easily add them. Index starts from 0 in a linked list.<\/p>\n\n\n\n<p><strong>Example<\/strong>: A program to create a linked list in java for students in a class based on their initials.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*; \n   public class AddElements { \n  public static void main(String args&#091;]) \n    { \n        LinkedList&lt;String&gt; lk = new LinkedList&lt;String&gt;(); \n   \n        lk.add(\"Bindu\"); \n        lk.add(\"Deepak\"); \n        lk.add(\"Krithika\");\n        \/\/add names with respect to index \n       lk.add(2,\"Gagan\");\n       lk.addFirst(\"Ankitha\");\n       \n        System.out.println(lk); \n    } \n} \n<\/code><\/pre>\n\n\n\n<p><strong>OUTPUT<\/strong>:<\/p>\n\n\n\n<p>[Ankitha, Bindu, Deepak, Gagan, Krithika]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"changing-elements-in-a-linked-list\"><strong>Changing Elements in a Linked List:&nbsp;<\/strong><\/h3>\n\n\n\n<p>We can change the inserted elements in the list too, and it can be done using the set() method. Every linked list is indexed. Thus the element which we wish to change is to be referenced by the index of it. Therefore, this method takes an index and the element we want to insert now at that index. For instance, a student's name was entered wrong and needed to be corrected, so the student name\u2019s index and the correct name will be taken in the set() method.<\/p>\n\n\n\n<p><strong>Example<\/strong>: A program to create a linked list in java for students in a class based on their initials.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*; \n   public class UpdateElements { \n  public static void main(String args&#091;]) \n    { \n        LinkedList&lt;String&gt; lk = new LinkedList&lt;String&gt;(); \n   \n        lk.add(\"Bindu\"); \n        lk.add(\"Deepak\"); \n        lk.add(\"Krithika\");\n        \/\/add names with respect to index \n       lk.add(2,\"Gagan\");\n       lk.addFirst(\"Ankitha\");\n       System.out.println(lk); \n \n       \/\/ set the updated element using index\n      lk.set(0,\"Anitha\");       \n       \n      System.out.println(lk); \n    } \n}\n<\/code><\/pre>\n\n\n\n<p><strong>OUTPUT<\/strong>:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;[Ankitha, Bindu, Deepak, Gagan, Krithika]<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;[Anitha, Bindu, Deepak, Gagan, Krithika]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"removing-elements-in-linked-list\"><strong>Removing Elements in Linked list:<\/strong><\/h3>\n\n\n\n<p>We can also remove different elements at the start, end and middle of the list. For example, Consider the student list in the example before. If some students left the class, then we have to remove their names. We can remove their names using their indexes or names themselves. We use the remove() method to remove elements in Linked lists.<\/p>\n\n\n\n<p><strong>Example<\/strong>: A program to create a linked list in Java to remove students from the list based on their initials.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.*; \n   public class RemoveElements { \n  public static void main(String args&#091;]) \n    { \n        LinkedList&lt;String&gt; lk = new LinkedList&lt;String&gt;(); \n   \n        lk.add(\"Bindu\"); \n        lk.add(\"Deepak\"); \n        lk.add(\"Krithika\");\n        \/\/add names with respect to index \n       lk.add(2,\"Gagan\");\n       lk.addFirst(\"Anitha\");\n       System.out.println(lk); \n       lk.remove(1);\n      System.out.println(lk); \n      lk.remove(\"Gagan\");\n     System.out.println(lk); \n    } \n}\n<\/code><\/pre>\n\n\n\n<p><strong>OUTPUT:<\/strong><\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;[Anitha, Bindu, Deepak, Gagan, Krithika]<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;[Anitha, Deepak, Gagan, Krithika]<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;[Anitha, Deepak, Krithika]<\/p>\n\n\n\n<p>Other methods present in the LinkedList class include,<\/p>\n\n\n\n<p>1. clear()- This method clears all elements in the linked list.<\/p>\n\n\n\n<p>2. clone() -This method returns the exact copy of the linked list.<\/p>\n\n\n\n<p>3. contains(Object O) - This method scans the list and returns 'True' if the element is present and 'False' if the given element is not present.<\/p>\n\n\n\n<p>4. get(int index_value) - This method goes to the index given and returns the element present. The variations of this method are getFirst(), which returns the first element of the list, and getLast() which, returns the last element.<\/p>\n\n\n\n<p>5. indexOf(Object o)- This method takes the object that is the element given and returns the index. The variation of this method is lastIndexOf(). This method returns the index of the element starting from the last position.&nbsp;<\/p>\n\n\n\n<p>6. listIterator(int index_value)- This method returns the whole linked list starting from the element present at the given index.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"constructors-in-linked-lists\"><strong>Constructors in Linked Lists:<\/strong><\/h3>\n\n\n\n<p>In a Linked list class, We need to declare objects, so constructors are invoked. There are different types of constructors in the Linked List class, which are,<\/p>\n\n\n\n<p>LinkedList()- This constructor is used to create an empty list.<\/p>\n\n\n\n<p>LinkedList(Collection co)- This constructor is used to create an ordered list of elements. These elements are from the given input.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"types-of-linked-lists-in-java\"><strong>Types of Linked Lists in Java:<\/strong><\/h3>\n\n\n\n<p>Internally in a Linked list class, the list created is a doubly-linked list.&nbsp;<\/p>\n\n\n\n<p>A double-linked list contains an extra pointer or, in this case, a reference.<\/p>\n\n\n\n<p>It is known as the previous reference. It references the address of the previous node.<\/p>\n\n\n\n<p><strong>Single Linked List:<\/strong><\/p>\n\n\n\n<p>Typically there is only one reference present in any Linked list. It is known as a singly linked list. The last node, known as 'tail' has a null value as it is a reference. In this list, traversal is allowed only in a single direction.<\/p>\n\n\n\n<p><strong>Doubly-Linked Lists:<\/strong><\/p>\n\n\n\n<p>Doubly linked lists contain two reference variables, one pointing toward the previous node address and another pointing towards the next node like every linked list. In this type of List, we can traverse it in any direction.<\/p>\n\n\n\n<p><strong>Circular Linked Lists:<\/strong><\/p>\n\n\n\n<p>Circular linked lists are the same as single-linked lists except that the last node references the first node. It overcomes the downside of single linked lists where we can traverse it only in a single direction.<\/p>\n\n\n\n<p><strong>Circular Doubly Linked Lists:<\/strong><\/p>\n\n\n\n<p>Circular Doubly Linked Lists are the same as a double-linked list where the previous reference of Head references Tail node. The last node references the head node. In this type of list, we can traverse the whole list in any direction.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"when-and-why-is-linked-list-used-over-arraylist\"><strong>When and Why is Linked List used over ArrayList?<\/strong><\/h3>\n\n\n\n<p>ArrayList allows fast random read access so that you can grab any element in constant time. In an ArrayList, adding or removing can be done from anywhere, but the end requires shifting all the elements over to make an opening or fill the gap. When you add more elements than the capacity of the array declared, a new array is allocated, and the old array is copied to the new one. As LinkedList uses a doubly-linked list, manipulation with LinkedList is quicker than ArrayList; also, no bit shifting is required in the memory. An ArrayList class can behave as a list only for the reason that it implements List only. LinkedList class can function as a list and queue both since it implements List and Deque interfaces. In a linked list, any extra memory is not wasted.<\/p>\n\n\n\n<p>We can make use of linked lists to implement stacks and queues.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"disadvantages-of-linked-list\"><strong>Disadvantages of Linked List:<\/strong><\/h3>\n\n\n\n<p>In a linked list, unlike other data structures, we cannot access random elements. The traversal of the linked list is time-consuming. Direct access to any element requires a traversal of the whole list. We store data and references and consider this a node; thus, it takes up a massive amount of memory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"applications-of-linked-lists\"><strong>Applications of Linked Lists:<\/strong><\/h3>\n\n\n\n<p>A linked list is useful for implementation stacks, queues and graph. The linked list is useful as an image viewer. In this context, since every image is linked to another, navigation is easy. Similarly, they can be used for navigating songs in a music player and pages in a web browser, among other applications.<\/p>\n\n\n\n<p>If you are looking for more such tutorials in other tech domains, check out<a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/marketing-foundations\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" Great Learning Academy. (opens in a new tab)\"> Great Learning Academy.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To date, Java is being used to develop many applications like Mobile and Web-based applications, Enterprise Applications, Big Data Technologies, etc. Java has seen significant growth over the years and has a bright future ahead. Without further ado, let\u2019s begin with the Java Tutorial.&nbsp; What is Java? Java is a high-level, robust, and object-oriented programming [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":16479,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36826],"content_type":[],"class_list":["post-16419","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-java"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Tutorial for Beginners | An Overview of Java - Great Learning<\/title>\n<meta name=\"description\" content=\"What is JAVA: This is the ultimate java tutorial for beginners. If you are looking at self-study resources, this is a great one to one to start with.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Tutorial for Beginners\" \/>\n<meta property=\"og:description\" content=\"What is JAVA: This is the ultimate java tutorial for beginners. If you are looking at self-study resources, this is a great one to one to start with.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-04T05:37:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-11T19:31:22+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"760\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"28 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Java Tutorial for Beginners\",\"datePublished\":\"2020-07-04T05:37:16+00:00\",\"dateModified\":\"2025-02-11T19:31:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/\"},\"wordCount\":6376,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/shutterstock_242761225.jpg\",\"keywords\":[\"java\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/\",\"name\":\"Java Tutorial for Beginners | An Overview of Java - Great Learning\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/shutterstock_242761225.jpg\",\"datePublished\":\"2020-07-04T05:37:16+00:00\",\"dateModified\":\"2025-02-11T19:31:22+00:00\",\"description\":\"What is JAVA: This is the ultimate java tutorial for beginners. If you are looking at self-study resources, this is a great one to one to start with.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/shutterstock_242761225.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/shutterstock_242761225.jpg\",\"width\":1000,\"height\":760,\"caption\":\"java tutorial\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-tutorial-for-beginners\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Tutorial for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java Tutorial for Beginners | An Overview of Java - Great Learning","description":"What is JAVA: This is the ultimate java tutorial for beginners. If you are looking at self-study resources, this is a great one to one to start with.","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:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/","og_locale":"en_US","og_type":"article","og_title":"Java Tutorial for Beginners","og_description":"What is JAVA: This is the ultimate java tutorial for beginners. If you are looking at self-study resources, this is a great one to one to start with.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2020-07-04T05:37:16+00:00","article_modified_time":"2025-02-11T19:31:22+00:00","og_image":[{"width":1000,"height":760,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"28 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Java Tutorial for Beginners","datePublished":"2020-07-04T05:37:16+00:00","dateModified":"2025-02-11T19:31:22+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/"},"wordCount":6376,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg","keywords":["java"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/","url":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/","name":"Java Tutorial for Beginners | An Overview of Java - Great Learning","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg","datePublished":"2020-07-04T05:37:16+00:00","dateModified":"2025-02-11T19:31:22+00:00","description":"What is JAVA: This is the ultimate java tutorial for beginners. If you are looking at self-study resources, this is a great one to one to start with.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg","width":1000,"height":760,"caption":"java tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-tutorial-for-beginners\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Java Tutorial for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",1000,760,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225-300x228.jpg",300,228,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225-768x584.jpg",768,584,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",1000,760,false],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",1000,760,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",1000,760,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",640,486,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",96,73,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2020\/06\/shutterstock_242761225.jpg",150,114,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"To date, Java is being used to develop many applications like Mobile and Web-based applications, Enterprise Applications, Big Data Technologies, etc. Java has seen significant growth over the years and has a bright future ahead. Without further ado, let\u2019s begin with the Java Tutorial.&nbsp; What is Java? Java is a high-level, robust, and object-oriented programming&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/16419","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=16419"}],"version-history":[{"count":67,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/16419\/revisions"}],"predecessor-version":[{"id":117139,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/16419\/revisions\/117139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/16479"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=16419"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=16419"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=16419"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=16419"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}