🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
All Subjects
Free · 121 Topics · No Signup

Java Notes

Core Java — syntax, OOP, collections, I/O and advanced topics — written by CodingNow 2.0's mentors. Free to read, structured to actually help you learn.

Java notes by CodingNow 2.0 cover 121 topics — from java home to java projects — each explained with short definitions, syntax and runnable code examples. They are 100% free, need no signup, and work as quick revision for college exams, Java interviews and CodingNow 2.0's mentor-led Java course in Pitampura, Delhi.

No notes found. Try a different search term, or browse all Java notes.

Java Tutorial

55 of 55 topics published
1

Java HOME

Java is one of the world's most widely used programming languages.

2

Java Intro

Java is a popular and powerful programming language, created in 1995.

3

Java Get Started

At W3Schools, you can try Java without installing anything.

4

Java Syntax

In the previous chapter, we created a Java file called Main.java , and we used the following code to print "Hello World" to the screen:

5

Statements

A computer program is a list of "instructions" to be "executed" by a computer.

6

Java Output

You learned from the previous chapter that you can use the println() method to output values or print text in Java:

7

Print Numbers

You can also use the println() method to print numbers.

8

Java Comments

Comments can be used to explain Java code, and to make it more readable. It can also be used to prevent execution when testing alternative code.

9

Java Variables

Variables are containers for storing data values.

10

Print Variables

The println() method is often used to display variables.

11

Multiple Variables

To declare more than one variable of the same type, you can use a comma-separated list:

12

Identifiers

All Java variables must be identified with unique names.

13

Constants (Final)

When you do not want a variable's value to change, use the final keyword.

14

Real-Life Examples

Often in our examples, we simplify variable names to match their data type (myInt or myNum for int types, myChar for char types, and so on). This is done to

15

Java Data Types

As explained in the previous chapter, a variable in Java must be a specified data type:

16

Numbers

Primitive number types are divided into two groups:

17

Booleans

Very often in programming, you will need a data type that can only have one of two values, like:

18

Characters

The char data type is used to store a single character. The character must be surrounded by single quotes, like 'A' or 'c':

19

Real-Life Example

Here's a real-life example of using different data types, to calculate and output the total cost of a number of items:

20

Non-primitive Types

Non-primitive data types are called reference types because they refer to objects.

21

The var Keyword

The var keyword was introduced in Java 10 (released in 2018).

22

Java Type Casting

Type casting means converting one data type into another. For example, turning an int into a double .

23

Java Operators

Operators are used to perform operations on variables and values.

24

Arithmetic

Arithmetic operators are used to perform common mathematical operations.

25

Assignment

Assignment operators are used to assign values to variables.

26

Comparison

Comparison operators are used to compare two values (or variables). This is important in programming, because it helps us to find answers and make decisions.

27

Logical

As with comparison operators, you can also test for true or false values with logical operators.

28

Precedence

When a calculation contains more than one operator, Java follows order of operations rules to decide which part to calculate first.

29

Java Strings

A String variable contains a collection of characters surrounded by double quotes ( "" ):

30

Concatenation

The + operator can be used between strings to combine them. This is called concatenation:

31

Numbers and Strings

Warning: WARNING! Java uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated.

32

Special Characters

Because strings must be written within quotes, Java will misunderstand this string, and generate an error:

33

Java Math

The Java Math class has many methods that allows you to perform mathematical tasks on numbers.

34

Java Booleans

Very often in programming, you will need a data type that can only have one of two values, like:

35

Real-Life Example

Let's use booleans in a real-life example where we want to find out if a person is old enough to vote.

36

Java If...Else

Conditions and if statements let you control the flow of your program - deciding which code runs, and which code is skipped.

37

else

The else statement lets you run a block of code when the condition in the if statement is false .

38

else if

Use the else if statement to specify a new condition to test if the first condition is false .

39

Short Hand If...Else

There is also a short-hand if else, which is known as the ternary operator because it consists of three operands.

40

Nested If

You can also place an if statement inside another if . This is called a nested if statement.

41

Logical Operators

You can combine or reverse conditions using logical operators. These work together with if , else , and else if to build more complex decisions.

42

Real-Life Examples

This example shows how you can use if..else to "open a door" if the user enters the correct code:

43

Java Switch

Instead of writing many if..else statements, you can use the switch statement.

44

Java While Loop

Loops can execute a block of code as long as a specified condition is true.

45

Do/While Loop

The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true. Then it will repeat

46

Real-Life Examples

To demonstrate a practical example of the while loop, we have created a simple "countdown" program:

47

Java For Loop

When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop:

48

Nested Loops

It is also possible to place a loop inside another loop. This is called a nested loop.

49

For-Each Loop

There is also a "for-each" loop, which is used exclusively to loop through elements in an array (or other data structures):

50

Real-Life Examples

To demonstrate a practical example of the for loop, let's create a program that counts to 100 by tens:

51

Java Break/Continue

You have already seen the break statement used in an earlier chapter of this tutorial. It was used to "jump out" of a switch statement.

52

Java Arrays

Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value.

53

Loop Through an Array

You can loop through the array elements with the for loop, and use the length property to specify how many times the loop should run.

54

Real-Life Examples

To demonstrate a practical example of using arrays, let's create a program that calculates the average of different ages:

55

Multidimensional Arrays

A multidimensional array is an array that contains other arrays.

Java Classes

21 of 21 topics published
62

Java OOP

OOP stands for Object-Oriented Programming.

63

Java Classes/Objects

Java is an object-oriented programming language.

64

Java Class Attributes

In the previous chapter, we used the term "variable" for x in the example (as shown below).

65

Java Class Methods

You learned from the Java Methods chapter that methods are declared within a class, and that they are used to perform certain actions:

66

Java Constructors

A constructor in Java is a special method that is used to initialize objects.

67

Java this Keyword

The this keyword in Java refers to the current object in a method or constructor.

68

Java Modifiers

By now, you are quite familiar with the public keyword that appears in almost all of our examples:

69

Non-Access Modifiers

Non-access modifiers do not control visibility (like public or private ), but instead add other features to classes, methods, and attributes.

70

Java Encapsulation

The meaning of Encapsulation, is to make sure that "sensitive" data is hidden from users. To achieve this, you must:

71

Java Packages / API

A package in Java is used to group related classes. Think of it as a folder in a file directory. We use packages to avoid name conflicts, and to write a better

72

Java Inheritance

Java Inheritance (Subclass and Superclass)

73

Java Polymorphism

Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance.

74

Java super Keyword

In Java, the super keyword is used to refer to the parent class of a subclass.

75

Java Inner Classes

In Java, it is also possible to nest classes (a class within a class). The purpose of nested classes is to group classes that belong together, which makes your

76

Java Abstraction

Data abstraction is the process of hiding certain details and showing only essential information to the user. Abstraction can be achieved with either abstract c

77

Java Interface

Another way to achieve abstraction in Java, is with interfaces.

78

Java Anonymous

An anonymous class is a class without a name. It is created and used at the same time.

79

Java Enum

An enum is a special "class" that represents a group of constants (unchangeable variables, like final variables).

80

Enum Constructor

An enum can also have a constructor just like a class.

81

Java User Input

The Scanner class is used to get user input, and it is found in the java.util package.

82

Java Date

Java does not have a built-in Date class, but we can import the java.time package to work with the date and time API. The package includes many date and time

Java Data Structures

16 of 16 topics published
98

Java Data Structures

Data structures are ways to store and organize data so you can use it efficiently.

99

Java Collections

Before we explore ArrayList , HashSet , HashMap , and other data structures in more detail, it's important to understand that all of these are part of someth

100

Java List

The List interface is part of the Java Collections Framework and represents an ordered collection of elements.

101

Java ArrayList

An ArrayList is like a resizable array.

102

Java LinkedList

In the previous chapter, you learned about the ArrayList class. The LinkedList class is almost identical to the ArrayList :

103

Java List Sorting

In the previous chapters, you learned how to use two popular lists in Java: ArrayList and LinkedList , which are found in the java.util package.

104

Java Set

The Set interface is part of the Java Collections Framework and is used to store a collection of unique elements.

105

Java HashSet

A HashSet is a collection of elements where every element is unique.

106

Java TreeSet

A TreeSet is a collection that stores unique elements in sorted order.

107

Java LinkedHashSet

A LinkedHashSet is a collection that stores unique elements and remembers the order they were added.

108

Java Map

The Map interface is a part of the Java Collections Framework and is used to store key-value pairs. Each key must be unique, but values can be duplicated.

109

Java HashMap

A HashMap stores items in key/value pairs, where each key maps to a specific value.

110

Java TreeMap

A TreeMap is a collection that stores key/value pairs in sorted order by key.

111

Java LinkedHashMap

A LinkedHashMap stores keys and values, and keeps them in the same order you put them in.

112

Java Iterator

An Iterator is an object that can be used to loop through collections, like ArrayList and HashSet .

113

Java Algorithms

In the previous chapters, you learned how data structures (like ArrayList , HashMap , etc.) are used to store and organize data.

Ready to go from notes to a real career?

Join CodingNow 2.0's Java course — live mentorship, hands-on projects, and 100% placement support in Delhi NCR.

Enroll Now — Free Demo Available

Java Notes – FAQs

What students search before reading Java notes.

Yes — all 121 Java topics on CodingNow 2.0 are completely free with no signup or paywall. Read them in the browser on mobile or desktop.
This hub covers 121 structured Java topics — from absolute basics to advanced, interview-ready concepts — each with short explanations and working code examples.
The notes are written to be self-study friendly, but for job-ready skills, projects and placement support, CodingNow 2.0's mentor-led Java course in Delhi (online + classroom) is the fastest path.
Yes. Each topic is concise and example-driven — ideal for last-minute revision before college exams, campus placements and Java job interviews in India.
Working AI/ML engineers and full-stack developers from Coding Now Tech Institute Gurukul of AI, Pitampura Delhi, aligned with our 2026 course curriculum.
WhatsApp
Call NowEnroll Now