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

What are the features of junit?

1089


How do you replace a string in java?

1047


give an example for encapsulation?

1091


What is public static?

1080


What is return used for in java?

1062


Is null false in java?

1227


What is the size of boolean variable?

1130


What is method reference in java?

1190


What is a parameter in java?

1029


Explain about interrupt() method of thread class ?

1168


What is difference between classpath and path variables in java?

1250


Can we override the static method?

1078


When is the finally clause of a try-catch-finally statement executed?

1133


How can we make a class singleton?

1124


What are the advantages of autoboxing?

1066