Curriculum
- 5 Sections
- 22 Lessons
- Lifetime
- Introduction to Java ProgrammingThis section provides a complete introduction to Java programming for beginners, helping you build a strong foundation before moving into advanced concepts. You will learn what Java is, how it works, and why it is one of the most widely used programming languages in the world. Starting with the basics, you’ll explore the history and key features of Java, followed by a step-by-step guide to installing the Java Development Kit (JDK) and setting up your development environment. You will also understand the core components of Java, including JDK, JRE, and JVM, and how they work together to execute Java programs. By the end of this section, you will write and run your first Java program, understand Java syntax, and gain confidence in setting up and working with Java on your system. This section is ideal for: Beginners with no programming experience College students starting Java Aspiring software developers Anyone looking to build a strong base in Java programming What You Will Learn in This Section Introduction to Java programming language History and features of Java Real-world applications of Java How to install and configure Java (JDK setup) Understanding JDK, JRE, and JVM Writing, compiling, and running your first Java program Basics of Java syntax and structure Why This Section is Important A strong understanding of Java fundamentals is essential for becoming a successful developer. This section ensures you clearly understand how Java works internally, which will make it easier to learn advanced topics like Object-Oriented Programming, frameworks, and real-world application development.3
- Java Basics (Core Fundamentals)This section of the Java course in Jaipur by Groot Academy focuses on building strong programming fundamentals using core Java concepts. If you are looking for a Java basics tutorial for beginners, this section will help you understand how to write clean, logical, and efficient Java programs. You will learn essential topics like Java variables, data types, operators, control statements, and loops, which are the foundation of all Java applications, including web development, Android apps, and enterprise software systems. Whether you are preparing for Java interviews, software development jobs, or learning Java from scratch, this section will help you develop strong problem-solving skills and coding confidence. SEO Keywords Used in This Section Java basics tutorial Java programming for beginners Java variables and data types Operators in Java with examples Control statements in Java Loops in Java tutorial Learn Java step by step Core Java fundamentals Java course in Jaipur Java training institute Jaipur7
- Object-Oriented Programming (OOP)This section covers Object-Oriented Programming (OOP) in Java, which is one of the most important topics for software development, coding interviews, and placements. OOP is the foundation of modern programming and is widely used in real-world applications such as enterprise systems, web applications, and Android development. In this section, you will learn how to design programs using classes and objects, implement inheritance for code reusability, apply polymorphism for flexibility, use encapsulation for data security, and understand abstraction for building scalable systems. Mastering OOP concepts in Java will help you write clean, reusable, and maintainable code, which is essential for becoming a professional software developer. What You Will Learn Classes and objects in Java Constructors and object initialization Inheritance and types of inheritance Polymorphism (method overloading and overriding) Encapsulation and data hiding Abstraction using abstract classes and interfaces5
- Core Java Concepts (Start Fresh)6
- Static Keyword in Java1
Arrays in Java
What is an Array in Java?
An array in Java is a collection of similar data type values stored in a single variable.
For example, if we want to store marks of five students, we can write:
int marks[] = {80, 85, 90, 75, 88};
Here, marks is an array that stores five integer values.
Without an array, we would need to create separate variables:
int mark1 = 80;
int mark2 = 85;
int mark3 = 90;
int mark4 = 75;
int mark5 = 88;
This approach is not good for large data. Arrays make the program shorter, cleaner, and easier to manage.
How Arrays Work in Java
Arrays work on the basis of index numbers. Each value inside an array is called an element, and every element has a specific index position.
Java array indexing starts from 0.
Example:
int marks[] = {80, 85, 90, 75, 88};
| Index | Value |
|---|---|
| 0 | 80 |
| 1 | 85 |
| 2 | 90 |
| 3 | 75 |
| 4 | 88 |
To access an array element, we use the array name with the index number.
System.out.println(marks[0]);
Output:
80
Here, marks[0] gives the first value of the array.
Array Declaration in Java
An array can be declared in two ways:
dataType arrayName[];
or
dataType[] arrayName;
Example:
int numbers[];
or
int[] numbers;
Both are valid, but int[] numbers; is commonly used because it clearly shows that numbers is an integer array.
Array Creation in Java
An array is created using the new keyword.
int numbers[] = new int[5];
This creates an integer array that can store 5 values.
We can assign values like this:
numbers[0] = 10;
numbers[1] = 20;
numbers[2] = 30;
numbers[3] = 40;
numbers[4] = 50;
Array Initialization in Java
Array initialization means assigning values to an array.
We can initialize an array directly:
int numbers[] = {10, 20, 30, 40, 50};
This is the easiest way when we already know the values.
Accessing Array Elements
Array elements are accessed using index numbers.
public class ArrayExample {
public static void main(String[] args) {
int numbers[] = {10, 20, 30, 40, 50};
System.out.println(numbers[0]);
System.out.println(numbers[1]);
System.out.println(numbers[2]);
}
}
Output:
10
20
30
Traversing an Array
Traversing means accessing all elements of an array one by one. We usually use loops to traverse arrays.
public class ArrayTraversal {
public static void main(String[] args) {
int marks[] = {80, 85, 90, 75, 88};
for(int i = 0; i < marks.length; i++) {
System.out.println(marks[i]);
}
}
}
Output:
80
85
90
75
88
Here, marks.length gives the total number of elements in the array.
Enhanced For Loop with Array
Java also provides an enhanced for loop to read array elements easily.
public class EnhancedForLoopExample {
public static void main(String[] args) {
int numbers[] = {10, 20, 30, 40, 50};
for(int num : numbers) {
System.out.println(num);
}
}
}
Output:
10
20
30
40
50
The enhanced for loop is useful when we only want to read values from an array.
Types of Arrays in Java
There are mainly two types of arrays in Java:
- One-Dimensional Array
- Two-Dimensional Array
One-Dimensional Array
A one-dimensional array stores data in a single row or list format.
Example:
int marks[] = {80, 85, 90, 75, 88};
This type of array is useful for storing simple list-based data like marks, roll numbers, prices, or ages.
Example program:
public class OneDArray {
public static void main(String[] args) {
int marks[] = {80, 85, 90, 75, 88};
for(int i = 0; i < marks.length; i++) {
System.out.println("Marks: " + marks[i]);
}
}
}
Two-Dimensional Array
A two-dimensional array stores data in rows and columns. It is also called a matrix.
Example:
int matrix[][] = {
{1, 2, 3},
{4, 5, 6}
};
Here, the array has 2 rows and 3 columns.
To access a value from a two-dimensional array, we use two index numbers:
System.out.println(matrix[0][1]);
Output:
2
Here, 0 is the row index and 1 is the column index.
Example program:
public class TwoDArray {
public static void main(String[] args) {
int matrix[][] = {
{1, 2, 3},
{4, 5, 6}
};
for(int i = 0; i < matrix.length; i++) {
for(int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
}
}
Output:
1 2 3
4 5 6
Important Points About Arrays
- Arrays store multiple values in a single variable.
- Arrays can store only the same type of data.
- Array indexing starts from
0. - Array size is fixed after creation.
- Array elements are accessed using index numbers.
- The
lengthproperty is used to find the size of an array. - Arrays work very well with loops.
- Arrays can be one-dimensional or multi-dimensional.
Advantages of Arrays
Arrays are useful because they help store and manage multiple values easily. They reduce the need to create many separate variables. Arrays also make it easier to process data using loops.
For example, we can calculate total marks, find the largest number, search for an element, or print all values using arrays.
Limitations of Arrays
Arrays also have some limitations. The size of an array is fixed, so we cannot easily increase or decrease its size after creation. Arrays can store only one type of data. If we need a flexible structure where data can be added or removed easily, then Java Collections such as ArrayList are better.
Real-Life Example of Array
Suppose a teacher wants to store marks of 5 students. Instead of creating 5 different variables, the teacher can use one array.
int studentMarks[] = {78, 85, 92, 67, 89};
Now the teacher can easily print all marks, calculate total marks, find average marks, or find the highest marks using loops.
Practice Programs for Students
Students should practice the following programs after learning arrays:
- Print all elements of an array
- Find the sum of array elements
- Find the largest number in an array
- Find the smallest number in an array
- Search an element in an array
- Reverse an array
- Count even and odd numbers in an array
- Print a two-dimensional array
- Add two matrices
- Find the average marks of students
Conclusion
Arrays in Java are used to store multiple values of the same data type in a single variable. They help make programs cleaner, shorter, and easier to manage. Arrays are very useful when working with list-based or table-based data.
In this lesson, students learned array declaration, array creation, initialization, indexing, accessing elements, traversing arrays using loops, one-dimensional arrays, two-dimensional arrays, advantages, limitations, and practical uses of arrays.
After completing arrays, the next important topic is Strings in Java, where students will learn how to store and process text data in Java.
