About 4,290,000 results
Open links in new tab
  1. One Dimensional Array in Java - GeeksforGeeks

    May 15, 2024 · The java.lang.reflect.Array.getLong() is an inbuilt method in Java and is used to return an element at the given index from a specified Array as a long. Syntax: Array.getLong(Object []array, int index) Parameters : This method accepts two mandatory parameters: array: The object array whose index is

  2. One Dimensional Array In Java – Tutorial & Example

    Apr 15, 2025 · Read the array length as sc.nextInt() and store it in the variable len and declare an array int[len]. 2) To store elements in to the array for i=0 to i<length of an array read the element using sc.nextInt() and store the element at the index a[i].

  3. How to get first and last element in an array in java?

    In Java, you can get the first and last elements of an array using the following approaches: 1. Using Array Indexing: To get the first element, you can access it using index 0. To get the last element, you can access it using the index array.length - 1. Here's an example:

  4. How to Find Length or Size of an Array in Java? - GeeksforGeeks

    Apr 18, 2025 · How to find the length of an array using the length property; Difference between length, length() and size() methods; Various approaches to find the array length, including loops and Stream API; Different Ways to Find the Length or Size of an Array 1. Using the length Property (Best and Easiest Way)

  5. How to find the index of an element in an array in Java?

    Nov 9, 2011 · Starting with Java 8, the general purpose solution for a primitive array arr, and a value to search val, is: return IntStream.range(0, arr.length).filter(i -> arr[i] == val).findFirst().orElse(-1);

  6. How to access array element by array index and length - Java2s

    Array size, arrayName.length, holds its length. The following code outputs the length of each array by using its length property. public static void main(String args[]) { int a1[] = new int[10]; int a2[] = {1, 2, 3, 4, 5}; int a3[] = {4, 3, 2, 1}; System.out.println("length of a1 is " + a1.length);

  7. How to Get the Index of a Specified Element in an Array in Java?

    Dec 9, 2024 · In Java, to find the index of a specific element in an array, we can iterate through it and checking each element. There are several ways to achieve this, including using loops, utility functions, Arrays.asList() for non-primitive arrays, and Streams.

  8. Array in Java. Understand how one-dimensional array… | by Adil ...

    Mar 18, 2023 · To access an element in array using its index, the formula to find the address of that element is given below. w= the number of bytes occupied by each element in array (integer take...

  9. One Dimensional Array in Java - Scientech Easy

    Feb 14, 2025 · There are basically two ways to create a one dimensional array in java that are as follows: 1. We can declare one-dimensional array and store values (or elements) directly at the time of its declaration, like this: int marks[ ] = { 90, 97, 95, 99, 100 }; // declare marks[ ] and initialize with five values.

  10. One Dimensional Array In Java | Operations & More …

    Length Property: Each array comes with a built-in property to determine its size. Immutable Size: While the size of the array is fixed, its elements can be modified. Supports Iteration: Arrays can be easily traversed using loops. Prone to IndexOutOfBoundsException: Accessing invalid indices will result in a runtime exception.

  11. Some results have been removed
Refresh