Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write java code to print second max number in the array

Answer Posted / laddu

import java.util.Arrays;
import java.util.Collections;
import java.util.*;
public class Main1 {
public static void main(String[] args) {
Integer[] numbers = { 8, 2, 7, 1, 4, 9, 5};
int min = (int) Collections.min(Arrays.asList(numbers));
int max = (int) Collections.max(Arrays.asList(numbers));

ArrayList s = new ArrayList(Arrays.asList(numbers));
Collections.sort(s);

System.out.println("Second element : " + s.get(s.size()-2));
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we create a thread in java?

1013


Write a java program that prints all the values given at command-line.

1006


Difference between object and reference?

1165


What is another word for methodology?

1013


What is java reflection?

969


Why are generics used?

957


What is the base class of all exception classes?

1057


Explain what pure virtual function is?

1012


Is oracle charging for java?

1020


what is use of functional interface in java 8?

1004


What is main in java?

1134


What are desktop procedures?

1041


What restrictions are placed on method overloading in java programming?

1045


What should I import for arraylist in java?

1026


What is anagram in java?

922