Learn Java Arrays from scratch with ease. The topics listed below will enhance your array programming to a great extent.
Java Arrays Tutorial
Learn Java Arrays from scratch with ease. The topics listed below will enhance your array programming to a great extent. Every topic improves your logic and makes you more keen to go for next. Every example has been illustrated in a simple and conceptual way. A rich variety of examples have been included which a user can download.
- Introduction
to Java Arrays
In this section you will be introduced to the concept of Arrays in Java Programming language. You will learn how the Array class in java helps the programmer to organize the same type of data into easily manageable format.
- Structure
of Java Arrays
Now lets study the structure of Arrays in java. Array is the most widely used data structure in java. It can contain multiple values of the same type. Moreover, arrays are always of fixed length i.e. the length of an array cannot be increased or decreased.
- Java Array
Declaration
As we declare a variable in Java, An Array variable is declared the same way. Array variable has a type and a valid Java identifier
- Java Array Initialization
After the declaration of an array variable, memory is allocated to it. The "new" operator is used for the allocation of memory to objects.
- Java Array Usage
We have already discussed that to refer an element within an array, we use the [] operator. The [] operator takes an "int" operand and returns the element at that index. We also know that the array indices start with zero, so the first element will be held by the 0 index.
- Copying Arrays
After learning all about arrays, there is still one interesting thing left to learn i.e. copying arrays. It means to copy data from one array to another.
- Two Dimensional Array
Two-dimensional arrays are defined as " an array of arrays". Since an array type is a first-class Java type, we can have an array of ints, etc.
- Multi Dimensional Array
So far we have studied about the one-dimensional and two-dimensional arrays. To store data in more dimensions a multi-dimensional array is used. A multi-dimensional array of dimension n is a collection of items.
Sorting Algorithms
- Bubble Sorting Algorithm
In this example we are going to sort integer values of an array using bubble sort.
- Bi-directional
Bubble Sort In Java
A alternative of bubble sort is bi-directional bubble sort. The bi-directional bubble sort compares each adjacent pair of elements in an array. - Heap Sort Algorithm
In Java
In this example we are going to sort integer values of an array using heap sort. There are two types of heap. First one is Max heap and second one is min heap.
- Insertion Sort
Algorithm In Java
Insertion sorting algorithm is similar to bubble sort. But insertion sort is more efficient than bubble sort because in insertion sort the elements comparisons are less as compare to bubble sort.
- Merge Sort
Algorithm In Java
In merge sorting algorithm unsorted values are divided into two equal parts iteratively. Then merge both parts and sort it. Then again merge the next part and sort it.
- Extra Storage Merge Sort in Java
In extra storage merge sorting algorithm the unsorted values divide into two equal parts iteratively and create an array for store data value in extra storage.
- Odd
Even Transposition Sort In Java
In this example we are going to sort integer values of an array using odd even transposition sort. Odd even transposition sort is a parallel sorting algorithm. Odd Even is based on the Bubble Sort technique.
- Quick Sort
Algorithm In Java
Quick sort algorithm is developed by C. A. R. Hoare. Quick sort is a comparison sort. The working of quick sort algorithm is depending on a divide-and-conquer strategy.
- Selection Sort
Algorithm In Java
In this example we are going to sort the values of an array using selection sort. In selection sorting algorithm, find the minimum value in the array then swap it first position.
- Java Array
- Convert ArrayList to
Array
- Convert Array to
ArrayList