- Installing The JDK
In order to begin with programming in Java, you need to have Java installed in your system. Java is also known as JDK (Java Development Kit). This lesson attempts to cover the detailed instructions to install JDK 8.0 in Windows. After the Java installation, you will need to set the environment variables, which has been covered in this lesson as well.
- Using Java Source Code File
You can download the source code files by clicking on the button "Download Source".
- Run our first Program
This lesson covers in detail, how to write your first Java program, which is technically a Hello World program. You will learn how to write the first program in Java using a very common windows text editor called as notepad++, then compile that program using command prompt followed by running the same program to get the output as Hello World.
- Command Line Argument
This lesson covers the details of how you can display the command line arguments by providing them at runtime. You will learn about the significance of String args in this lesson and how you can get the command line argument displayed on the console when you run your Java program.
- Downloading Eclipse
You need to install Java to do any Java programming on your system; however, it could ad be the very tedious task to compile and run the program each time using the command prompt. So, you can make your task easy by using an Integrated Development Environment or IDE. This lesson will cover the detailed procedure of downloading and installing a famous Java IDE known as Eclipse. The latest version which is Oxygen has been taken for the demonstration in this course. After the installation is complete, you will learn to create a project in Eclipse.
- Hello India
This lesson covers the details of creating, compiling, and executing your first java program using the Eclipse IDE. You will learn to create a Java class and write your first Java program followed by running that program on eclipse and displaying Hello India on console.
This lesson will deal with variables. Variables are defined on basis of predefined data types, classes and user define datatypes. Variables in Java can be defined anywhere in the code (inside a class, inside a method or as a method argument) and can have different modifiers. Depending on these conditions variables in Java are Instance Variable, Static Variable, Local Variable, and Method Parameter. An instance variable is associated with an instance of the class (also called object). Access works with these objects. Instance variables can have any access control and can be marked final or transient. Instance variables marked as final cannot be changed after a value has been assigned to them.
- Getting User Input
This lesson attempts to cover the details of getting input from You. If you want to accept input from You to perform any operations, that can be done by using the Scanner class which belongs to the package java.util. In order to use this class, you need to import it and after importing it, you can create an instance of this class which allows you to accept input from You.
- Building a Basic Calculator
This lesson will cover the implementation of input from You to build a simple calculator. You will learn to build an application which will enable You to enter a couple of numbers and perform a simple addition of two numbers and display the result of an addition of two numbers on the console.
- Math Operators
This lesson will cover the implementation of mathematical operators to perform different mathematical operations. These operators are + for addition, - for subtraction, * for multiplication, / for division and % for remainder.
- Increment Operators
This lesson will cover the increment operators. The increment operators increment the value of the variable by one. They are defined in two types of notations which are prefix and postfix notations. Like increment operators, there are decrement operators as well, these decrease the value of the variable by one and follow the same notations as increment operators. Apart from these, you will also learn about the assignment operators in this lesson.
- If Statement
This lesson will cover the conditional statement known as the if-else statement. An if-else statement is used to implement a condition in the program. The if the statement contains a condition which is evaluated, and when the condition is true, the statement in the code block of if statement is executed. Otherwise, when the condition is false, the statement inside the code block of else statement is executed. You will learn in detail the syntax and implementation of an if-else statement in this lesson.
- Logical Operators
This lesson will cover the logical operators. Logical operators are also sometimes referred to as “Boolean operator”. In Java programming, logical operators are those operators which return a Boolean result that is based on the Boolean result of one or two other expressions. These expressions which make use of the logical operators are referred to as “compound expressions” because the effect of the logical operators is to let you combine two or more condition tests into a single expression. The statement is known as an if-else statement. An if-else statement is used to implement a condition in the program. The if the statement contains a condition which is evaluated, and when the condition is true, the statement in the code.
- Switch Statement
This lesson covers the details of implementing a switch statement in a program. A switch statement allows a variable to be tested for equality against a list of values. Each of these values is referred to as the case, the variable which is switched on is evaluated for each case.
- While Loop
This lesson will cover the details of implementing a while loop. A loop statement allows us to execute a statement or group of statements multiple. A while loop is a repetition control structure that allows you to write a block of code which is executed until a specific condition evaluates to false. This is also a common loop used to iterate a part of the program several times. If the number of iteration is not fixed, it is recommended to use while loop.
- Using Multiple Classes
This lesson will cover the details of using more than one class in an existing project or. In earlier lessons, the entire work was done using a simple class named ICT, however, you will learn to add more than one classes in the project along with the benefits of using multiple classes which is very significant when dealing with a bigger project which consists of different modules.
- Use Methods with Parameters
This lesson will cover the details of using methods. In Java, a method is referred to as a collection of executable statements which are combined together to perform the desired operation. For example, if you invoke the method println() of System.out class, then the system actually executes several statements in order to display a message on the console. Methods are of two types, parameterized and non-parameterized, where the former accepts no arguments and the latter accepts arguments. You will learn to create your own methods with or without return values, invoke a method with or without parameters, and apply method abstraction in the program design.
- Many Methods and Instances
This lesson will cover something called method overloading. In the earlier lesson, you learned about methods and creating your own methods. Method overloading is the concept in Java which allows you to create more than one versions of the same method, but different from each other in terms of the arguments that they accept and they could be different in terms of the return types as well. You will learn to create multiple methods and you will also learn to invoke these methods using different instances of the same class.
This lesson will cover all about constructors. A constructor in Java is a block of code which is the same as a method which is invoked when the instance of an object is created. However, there are some differences between a constructor and method. The first difference is that a constructor doesn’t have a return type and the constructor always has the same name as the name of the class. Unlike methods, constructors are not considered members of a class and a constructor is called automatically when a new instance of an object is created.
- Nested If Statements
This lesson will cover all about Nested-If statement. In Java or any other programming language, when the if or if-else statement is embedded inside another if block or else block, then this is referred to as the nested-if statement. In this lesson, you will learn to implement the nested if statement in your code with the help of a demonstration.
- Else If Statement
This lesson will cover all about Else-If statement. In Java or any other programming language, the else-if statement is statement is used to implement multiple decisions which is not possible in case of traditional if-else statement which is limited to only a couple of decisions. You can combine an else and an if to make an else if and test a whole range of mutually exclusive possibilities
- Conditional Operators
This lesson will cover all about conditional operators. In Java, the conditional operator is also referred to as the ternary operator, which is the only operator that takes three operands. Java conditional operator is a one-liner replacement for if-else statement and used very frequently by the Java programmers to implement conditions in a single line. You can make use conditional operator to replace switch also.
- Simple Averaging Program
This lesson will implement the learning of earlier lessons here and will cover the details by demonstrating a simple program to calculate the average of ten inputs which are given by You and display the average of these inputs on the console. The program will make use of the Scanner class to take inputs from You and will also use mathematical operators for computing the sum and average of these ten inputs from You and display the output on the console.
- For Loops
This lesson will cover the details of for loop. A loop statement allows you to execute a statement or group of statements multiple times and, for loop is the most widely used loop in Java and all other programming languages to iterate a part of the program several times. If the number of iteration is fixed, it is recommended to use for loop.
- Compound Interest Program
This lesson will demonstrate the simple program to calculate the number of subscribers which are added per day at a specific rate. This program is similar to a program which computes the compound interest on a specific amount after a fixed period of time at a specific rate and it uses the same expression to calculate the number of subscribers added on a daily basis.
- Do While Loops
This lesson will cover the details of the do-while loop which is also another type of loop used in Java and other programming languages. The do-while loop is used to iterate a part of the program several times. If the number of iteration is not fixed and you must have to execute the loop at least once, it is recommended to use do-while loop.
- Math Class Methods
This lesson will cover the different methods which belong to Math class in Java and are capable of performing some desired mathematical operations. Complex mathematical operations can be performed by simply calling the methods of the Math class which is a built-in class in Java. Some of the popular methods of this class are abs(), ceil(), floor(), max(), min(), pow(), sqrt() etc. You will learn to implement these methods in your code in order to produce the desired output
- Random Number Generator
This lesson will deal with something called a random number, which can be generated easily in Java using the Random class which is a built-in class in Java. The random class in Java belongs to the package java.util and can be imported into your program. You will learn to create the object of the Random class and through that object, you will be able to generate random numbers.
- Introduction to Arrays
This lesson will cover in detail about the arrays. Arrays are very important in every programming language. The Java array is a collection of similar type data elements which are stored in continuous memory locations. However, the only fixed set of elements can be stored in an array. You will learn to declare and initialize an array and you will also learn to display the elements of the array by using the loops.
- Creating An Array Table
This lesson will cover more details of the arrays and how you can display the array elements in a tabular form which will have a table header where the element will be displayed on the console with the corresponding index in the form of a table. You will learn to create the array table step by step in this lesson.
- Summing Elements of Arrays
This lesson will cover further details of the arrays. If you want to perform certain operations with the arrays, these can be done very easily, these operations can be like adding the array elements together and displaying the sum of these elements. In this lesson, you will learn to add the array elements together by looping through the array using a loop and then adding these array elements and displaying the sum of these elements together.
- Array Elements As Counters
This lesson will cover in the detail, how you can use the array elements to display the count of occurrence of any particular number. In this lesson, you will get a scenario to roll a dice 1000 times and then count the frequency of occurrences of numbers which will appear on the dice each time when it is rolled. This program will make use of the array as well as the random number generator which you’ve learned in earlier lesson.
- Enhanced For Loop
This lesson will cover in the detail a different type of loop which is an enhanced for loop. This loop is also known as the for-each loop. The enhanced for-loop is a popular feature introduced with the Java SE platform in version 5.0. It has a simple structure allows you to simplify the code by presenting for-loops that visit each element of an array/collection without explicitly expressing how you go from element to element.
- Arrays in Methods
This lesson will cover how arrays can be used in methods as well. In earlier lessons, you’ve already covered about the methods in detail. In this lesson, you will learn to create a method which will accept an array as an argument and increment each element of the array by a fixed number, then you will learn to invoke this method to see the desired output.
- Multidimensional Arrays
This lesson will cover in detail about the multi-dimensional arrays. I earlier lessons, you’ve already learned about the arrays, which are very important in every programming language. The Java array is a collection of similar type data elements which are stored in continuous memory locations. The arrays are categorized as Single dimensional arrays and multidimensional arrays. Multidimensional arrays are 2D, 3D, 4D arrays etc. You will learn to declare and initialize a 2D array in this lesson and you will also learn to access the elements of the multi-dimensional array by using the loop.
- Table for Multi Arrays
This lesson will cover in detail about representing the elements of the two-dimensional array in the form of a table. You will learn to create an array and display the elements of an array in tabular form with the help of some basic formatting which you can do easily.
- Variable Length Arguments
This lesson will cover all about variable length arguments. When you create a method, you set it in such a way that it accepts certain parameters which can be passed while invoking the method. These parameters or arguments are fixed. However, when you aren’t sure about how many arguments you wish to pass in the method, then you declare a method which is set to accept variable length arguments. This is done by simply putting three dots in between the datatype and the identifier. In this lesson, you will learn to implement this in detail.
- Time Class
This lesson will cover all about the time class. In order to display the time in 24-hour format or military format, you can build your application to display the time in the desired format. In this lesson, you will learn this in detail, how you can build an application which allows you to set the time and display at the same time in 24-hour format or military format.
- Display Regular time
This lesson will be covering further what has been covered in the previous chapter. You will learn to build your application to display the time in 12-hour format or the regular format. As done in an earlier lesson, you will be allowed to set the time and display at the same time in 12-hour format or regular format.
- Multiple Constructors
In earlier lesson, you learned about method overloading. This lesson will cover something called constructor overloading. Constructor overloading is the concept in Java which allows you to create more than one versions of the same constructor, but different from each other in terms of the arguments that they accept. In this lesson, you will learn to create multiple constructors and you will also learn to call these constructor methods.
- Set and Get Methods
This lesson will cover something called getters and setters. Getters and Setters are also known as getting and Set methods in Java which help in achieving encapsulation which is an important concept of Object-Oriented Programming. In Java, getter and setter are two conventional methods that are used for retrieving and updating the value of a variable. If you want that the fields which are declared in the class remain unmodified by the other users, these can field can only be accessed through the methods, then getters and setters are created to restrict access to the fields of the class. In this lesson, you will learn to create the getters and setters.
- Building Objects for Constructors
In an earlier lesson, you learned about something called as constructor overloading, in which you created multiple copies of the constructor. However, different in terms of the arguments that they accept. In order to access these copies of constructors, you will need separate objects which call respective constructor methods. This lesson will cover in detail, how you can create objects for these multiple constructors. In this lesson, you will learn to build these objects in detail.
This lesson will cover the details of a built-in method of each and every class which is known as the toString() method. This method returns the string representation of the object. If you print any object, java compiler internally calls the toString() method on the object. In order to get the desired output, you can also override this method. In this lesson, you will learn to override this method to get the string displayed in the desired format.
This lesson will cover Composition which is an interesting and tricky topic in Java. Composition in java is the design technique to implement has-a relationship in classes. You can use java inheritance or Object composition in java for code reuse. Java composition is achieved by using instance variables that refer to other objects. In this lesson, you will learn to implement the concept of composition in detail.
- Java: A Practical Approach - Final Quiz