About 30,600,000 results
Open links in new tab
  1. Check If a Value is Present in an Array in Java - GeeksforGeeks

    Apr 15, 2025 · There are numerous approaches to check whether a specific element is present in this Array or not in Java. These are, Using the Linear Search method; Using the Binary Search …

  2. How do I determine whether an array contains a particular value in Java

    Jul 15, 2009 · You can use the Arrays class to perform a binary search for the value. If your array is not sorted, you will have to use the sort functions in the same class to sort the array, then …

  3. Searching Elements in an Array | Array Operations - GeeksforGeeks

    May 23, 2024 · In this post, we will look into search operation in an Array, i.e., how to search an element in an Array, such as: Searching in an Unsorted Array using Linear Search; Searching …

  4. Find the Index of an Array Element in Java - GeeksforGeeks

    Dec 9, 2024 · Here, we will find the position or you can index of a specific element in given array. Example: Input: a[] = { 5, 4, 6, 1, 3, 2, 7, 8, 9 }, element = 7 Output: 6 1. Using a Simple Loop. …

  5. Finding an element in an array in Java - Stack Overflow

    Nov 25, 2013 · With Java 8, you can do this: You'd need to do. if you're working with objects. True, but if you're working with an ArrayList, doing boolean found = haystack.contains(needle) …

  6. java - How to create a search method for an array - Stack Overflow

    If you're not forced by your teacher to use for or for-each cycle in the search function - this is how to do a full scan the Java 8 way. public Optional<Student> findFirstByName(final String name) …

  7. Check if a Java Array Contains a Value - Baeldung

    Sep 7, 2024 · In this article, we’ll look at different ways to search an array for a specified value. We’ll also compare how these perform using JMH (the Java Microbenchmark Harness) to …

  8. 4 Ways to Search Java Array to Find an Element or Object - Blogger

    Aug 11, 2021 · Since Java programmer uses array a lot, they often faced challenges to search element in Java array e.g. How to check if array contains an element or not. This Java tutorial …

  9. Find the Index of an Element in a Java Array - Baeldung

    Dec 7, 2023 · In this tutorial, we’ll discuss various methods, with code examples, for finding the index of an array element using both Java’s built-in APIs and a third-party library. This can be …

  10. Arrays.binarySearch() in Java with Examples | Set 1

    Nov 25, 2024 · In Java, the Arrays.binarySearch() method searches the specified array of the given data type for the specified value using the binary search algorithm. The array must be …

  11. Some results have been removed
Refresh