Best Answer

Method 1:

Sort the array in descending order, compare 1st and 2nd if not same , return 2nd if same return -1

Method 2:

Find the largest number in the array, initialize another array with dimension 1 less than of original. Copy the array elements from the original array minus the largest element. not select largest from the second array and compare with the previous one if not same return the second largest if same return -1

Q: Write a function in java that accepts an array of integers and returns the second largest integer in the array Return -1 if there is no second largest?

Write your answer...

Submit

Still have questions?

Continue Learning about Math & Arithmetic

There is no largest integers: they go on for ever.

The two largest integers when multiplied together is 48 are 6 and 8. To get the single highest integer when multiplying it would be 1 and 48.

The greatest common factor

-1

There is no such thing. whatever integer you name, no matter how large it is, I can always name an integer that's larger than the one you named. You may have not understood the question entirely. But i may be wrong. What is the SINGLE LARGEST POSITIVE INTEGER. This can be 9. 9 is a single integer, and is the largest of the positive single integers. 9 can be an answer.

Related questions

There is no largest integers: they go on for ever.

var largest : integer largest = array[0] for n : integer in array if n > largest largest = n endif endfor return largest

For x, which is the largest integer of nconsecutive positive integers of which the smallest is m:x = m + n - 1

The two largest integers when multiplied together is 48 are 6 and 8. To get the single highest integer when multiplying it would be 1 and 48.

The greatest common factor

The largest integer is 103 because 101+102+103 = 306

-1

Let the smallest integer be 2n, the next integer is 2n + 2, and the largest one is 2n + 4. Then, we have:2n + (2n + 2) = (2n + 4) + 164n + 2 = 2n + 202n = 18 the smallest integer2n + 2 = 18 + 2 = 20 the next one2n + 4 = 18 + 4 = 22 the largest integerCheck

The largest integer of 369 is 3 because it represents 300

9,11,13

x = the largest integer not exceeding x

There is no such thing. whatever integer you name, no matter how large it is, I can always name an integer that's larger than the one you named. You may have not understood the question entirely. But i may be wrong. What is the SINGLE LARGEST POSITIVE INTEGER. This can be 9. 9 is a single integer, and is the largest of the positive single integers. 9 can be an answer.