0% found this document useful (0 votes)
2 views

Java Notes

Java arrays are objects that store elements of the same data type in contiguous memory, with indexing starting at 0. Method overloading allows multiple methods in a class to have the same name but different parameter lists, enhancing code readability. This feature helps in performing operations like addition with varying numbers of arguments without confusion.

Uploaded by

Anant Kanwale
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Notes

Java arrays are objects that store elements of the same data type in contiguous memory, with indexing starting at 0. Method overloading allows multiple methods in a class to have the same name but different parameter lists, enhancing code readability. This feature helps in performing operations like addition with varying numbers of arguments without confusion.

Uploaded by

Anant Kanwale
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Arrays

An array is typically a grouping of elements of the same kind that are stored in a single, contiguous
block of memory.

Java array is an object which contains elements of a similar data type. Additionally, The elements of
an array are stored in a contiguous memory location. It is a data structure where we store similar
elements. We can store only a fixed set of elements in a Java array.

Array in Java is index-based, the first element of the array is stored at the 0th index, 2nd element is
stored on 1st index and so on.

In contrast to C/C++, the length member allows us to obtain the array's length. We must utilise the
sizeof operator in C/C++.

Method Overloading in Java

Method overloading in Java is the feature that enables defining several methods in a class having the
same name but with different parameters lists. These algorithms may vary with regard to the number
or type of parameters. When a method is called, Java decides which version of it to execute
depending on the arguments given. If we have to perform only one operation, having the same name
of the methods increases the readability of the program.

Suppose you have to perform the addition of the given numbers, but there can be any number of
arguments if you write the method such as a(int,int) for two parameters, and b(int,int,int) for three
parameters then it may be difficult for you as well as other programmers to understand the behavior
of the method because its name differs. Here's an explanation with real-life examples:

Math Operations:

You might also like