About 2,600,000 results
Open links in new tab
  1. Second Largest Element in an Array - GeeksforGeeks

    Feb 10, 2025 · Given an array of positive integers arr [] of size n, the task is to find second largest distinct element in the array. Note: If the second largest element does not exist, return -1. Examples: Explanation: The largest element of the array is …

  2. Java Program to find Second Largest Number in an Array

    In this article, you will see how to find Second largest number in an Array using Java. To understand this program, you should have the basic knowledge of an integer array and the looping concept. Let’s see a few examples here, Example …

  3. Find 2nd Largest Number in an Array in Java - Online Tutorials …

    Learn how to find the 2nd largest number in an array using Java with this comprehensive guide and example code.

  4. finding the second largest value in an array using java

    Feb 16, 2019 · Very easy answer using java streams. public static int secondLargestNumberInArray(Integer[] numbers) { return Arrays.stream(numbers).sorted(Collections.reverseOrder()).skip(1).findFirst().get(); } In case you want to use primitive method parameter

  5. Java Program to find Second Largest Number in an Array

    Dec 8, 2024 · We can find the second largest number in an array in java by sorting the array and returning the 2nd largest number. Let's see the full example to find the second largest number in java array.

  6. Java 8 – Find Second Largest number in an Arrays or List or …

    In this article, we will discuss how to find second largest number in an Arrays and List using Java 8 Stream. Read Java – Find Second Largest number in an Arrays or List ? for finding second largest number without using Java 8 syntax. 1. Finding Second Largest number in an Arrays :

  7. Java 8 – How to find the Second Largest Number in an Array?

    Jan 17, 2023 · Find the Second Largest Number in the array using Java 8 Stream. Learn how to do it using two different ways. 1. Skip method 2. Sort and Limit...

  8. Finding the second highest number in array in Java

    To find the second highest is actually quite simple: static int secondHighest(int... nums) { int high1 = Integer.MIN_VALUE; int high2 = Integer.MIN_VALUE; for (int num : nums) { if (num > high1) { high2 = high1; high1 = num; } else if (num > high2) { high2 = …

  9. Java Code to find the second largest number in an Array

    To find the second largest number in a Java array, we can employ the approach of sorting the array in ascending order and then returning the second-to-last element as the second largest number. Output:

  10. Java Program to Find the Second Largest Number in an Array

    This Java program efficiently finds the second-largest number in an array by maintaining two variables for the largest and second-largest values. The program handles arrays with duplicate elements and correctly outputs the second-largest number …

  11. Some results have been removed