Core Java Archive
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 …
Using Scanner class: We can construct the array by reading the size of array using Scanner object Read elements are store into array:
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 …
Find the Sum of array elements: Find the even numbers count and odd numbers count in array:
Storing Account type records into Array:
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 …
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 …
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 …
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 …
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) …