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 / murali

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class SecondMax {
public static void main(String[] args) {
String [] str={"3","4","2","1"};
List<String> ls=Arrays.asList(str);
Collections.sort(ls);
System.out.println(ls.size()-1);

}

}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which object oriented concept is achieved by using overloading and overriding?

1100


What is the internal implementation of set in java?

917


What is the purpose of the return statement?

1036


Is string a class in java?

974


How do you trim a space in java?

975


Where import statement is used in a java program?

1120


What is data type example?

956


How many types of constructors are used in java?

1173


Is void a keyword in java?

1008


What are java packages? What is the significance of packages?

1004


Is main an identifier?

1004


What is a protected method?

1134


Is hashset ordered java?

1078


is there a separate stack for each thread in java? : Java thread

970


Can we clone singleton object?

1055