JAVA PROGRAMMING
Before We Begin
In this pre-requisite chapter, you'll learn how to install Java on your Windows system. You'll learn to download and install the Eclipse IDE on which you will develop your Java programs. We'll also discuss the various coding conventions used throughout the different examples all over this blog...
1.1: Installing Java
To develop programs in Java, you will need to download and install the Java Development Kit, or JDK. Installing Java on Windows is pretty easy. Follow the steps given below, and you should be all good.

Remember, it is always best to work with the latest version of Java available.

Go to Java Downloads Page, and then click on "Java Platform (JDK 9). You will reach the page "Java SE Development Kit 9 Downloads." Check the radio button for "Accept License Agreement", and click on the download link beside "Windows".

Run the downloaded file, "jdk-9.0.xx_windows-x64_bin.exe". Here 'xx' denotes the version number of the JDK. Automatically the JDK will be installed in "C:\Program Files\Java\jdk-9.0.xx".

After this is done, you will need to include the JDK's 'bin' directory in your computer's Windows Shell PATH system variable. You cannot execute any programs if this is not done. Go to "Control Panel", click on "System and Security", then on "System", and finally on "Advanced System Settings".

A small window - System Properties - should pop up. Go the the tab "Advanced", and then click on "Environment Variables". In the box for System Variables, click on "New". Fill in the Variable name as "PATH", and the Variable value as "c:\Program Files\Java\jdk-9.0.xx\bin."

Click on "Okay", and you have successfully installed Java / JDK on your system.
1.2: Installing Eclipse
The Eclipse Integrated Development Environment (IDE), provides us with an interface for efficiently developing and managing our Java Projects. While a lot of books, videos, or blogs might teach you how to develop Java programs using the Command Line Interface (CLI) of your system, this blog encourages the use of IDEs (in this case Eclipse).

NOTE: You will surely encounter examples where we may run programs through the command line.

Go to Eclipse Downloads, and look for "Get Eclipse Oxygen". Under that, you should find a link called Download Packages.

You will be shown a list of products. For "Eclipse IDE for Java Developers", you will have download links for either a 32-bit system or a 64-bit system. Click on the one you prefer.

You will be directed to another page with a download link. Click on "Download". A zip folder should download. Extract the folder to any location you prefer (Anywhere away from C should be good). Inside the extracted folder, now called "eclipse folder", you will have an "Eclipse" application file. Click on it, and your application will start.

On startup, the application will ask you to set a "Select a directory as workspace". Click on "Browse", and select your preferred folder, where you would like to store all your projects. This folder will be called your "workspace".

Select your folder, and then click on "Launch", and Eclipse will open.
1.3: Creating your First Project
Once Eclipse has launched, click on 'File', then 'New', and then 'Java Project'.

A pop-up window for New Java Project appear. Enter a project name, let's say, "My First Project". In the "JRE" section, select the radio button for "Use default JRE". Next, in the "Project Layout" section, select the radio button for "Use project folder as root for sources and class files".

Click on "Finish". On the left hand side of your window, you will see a folder "My First Project" has been created. This is your project folder, and is saved inside your "workspace" folder you had selected earlier when starting Eclipse.

Next, right-click on "My First Project", then "New", and then on "Class". Another pop-up window for New Java Class will appear. The "Source Folder" field will show as "My First Project". In the "Name" field, enter "myFirstProject", without any spaces.

Next, you will find four radio buttons for "Modifiers". Click on the radio button for "public".

At the bottom, you will find four checkboxes. Select the checkbox for "public static void main(String args[])"

Click on "Finish", and you will have your project file "myFirstProject.java" created. This is how the content of the file will look:


public class myFirstProject {

        public static void main(String[] args) {
                // TODO Auto-generated method stub

        }

}            
            

And you have successfully learnt to create a new Java project in Eclipse!
1.4: Conventions used in this blog
Coding conventions are a set of recommended guidelines for any programming language. These guidelines ensure that programmers make use of specific programming styles, methods, or practices for a particular project they undertake.

In a real-world project, conventions play a very important role, as they ensure that programmers make their code readable and maintainable, and follow a pre-defined standard. This makes the code easy to modify, especially for those who might join the project after the original code developer has moved on.

All code that you will encounter in this blog shall follow the following convention, so that you may be able to follow what is being shared without difficulty, and recognize specific important pieces of information on your own:

1: Naming Conventions
Professional software developers follow different naming conventions for their code. We shall follow the "camel case" style of naming any program, package, class, method, or variable.

The camel case style of naming is as follows:

    i. All names given to any program, package, class, method, or variable, must sufficiently hint towards the reasoning for that particular program, package, class, method, or variable. For example:
      a) A variable holding a number divisible by 5 must be named as 'numberDivisibleByFive'.
      b) A method that calculates the factorial of a number must be named as 'calculateFactorial'.

    ii. The name given to each program, package, class, method, or variable will consist of more than one word, without spaces or underscores in between. The first word will be all in lower-case, while those following the first word shall have their first initial in upper-case. For example:
      a) A variable 'numberDivisibleByFive'.
      b) A method 'calculateFactorial'.

    iii. The name of any program, package, class, method, or variable shall not begin with a number. For example:
      a) Use 'tenMultipliedByNumber' instead of '10MultipliedByNumber'.
      b) Use 'twentyFourHourClock' instead of '24HourClock'.

2: Displaying Code
Each chapter will be filled with a number of examples, which we shall analyze thoroughly.

    i. So that there is clarity of content, all code shall be enclosed within special code windows and displayed as below:
    
    public class accessingPrivateMembers {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
                
            classWithPrivateMembers object = new classWithPrivateMembers();
            object.setNumber(10);
            System.out.println("Number: " + object.number);
            object.displayNumberMultipliedByTwo();
    
        }
    
    }                   
                                

    ii. Any single lines of code being analyzed shall be displayed as below:
    
    classWithPrivateMembers object = new classWithPrivateMembers();
                                

    iii. Special keywords and names that have been picked up from code, but need to be analyzed in an explanation shall be highlighted and dislplaued in the following manner:

    "The private keyword is an access-specifier that allows users to define which objects or parts of their program might be access or manipulate..."