Core Java Archive

Java – ArrayIndexOutOfBoundsException

ArrayIndexOutOfBoundsException occurs when we try to access array elements which are out of bounds. Often we try to access element beyond the size of the array. for example, if we have a size 10 arrays …

Java – Reading Array

Using Scanner class: We can construct the array by reading the size of array using Scanner object Read elements are store into array:

Java – for each loop

for-each loop: It is also called enhanced for loop. It is introduced in JDK 1.5 It is used to process array elements easily. For each loop iterate all elements of array without taking bounds(lower and …

Java – Array as parameter

Passing array as a parameter to a method: We can address of array as a parameter to method. Using the address, we can process elements of that array. Passing array is nothing but passing memory …

Java – Linear Search

Linear Search: Searching algorithm to check whether the element is present or not in the array. In linear search, index element always compare with the element to be searched. If element found, it returns the …

Java – Binary Search

Binary Search: Another searching algorithm to search for an element in array. Binary search can apply only on sorted array In this searching process, we find the mid element and compare with element to be …

Java – Two dimensional arrays

Two dimensional arrays: One dimensional array is linear, the elements store side by side. Two dimensional arrays are used to process elements in rows and columns. We can declare a 2 dimensional array in different …

Java – Two dimensional array length

Length of array: When we call length variable on array object, it returns number of rows as length. We need to call length variable on each row to find the size of row(number of columns) …

Courses Enquiry Form