write java code to print second max number in the array

Answers were Sorted based on User's Feedback



write java code to print second max number in the array..

Answer / rajesh s

If we give negative values, what would be the Rajaraman
code begaves????

Is This Answer Correct ?    0 Yes 1 No

write java code to print second max number in the array..

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

More Core Java Interview Questions

Which non-unicode letter characters may be used as the first character of an identifier?

0 Answers  


Define interface?

3 Answers   MindCracker,


What is Applet Stub Interface ?

0 Answers  


What is nested loop? What is dangling else condition in it?

0 Answers   Ericsson,


What is stack example?

0 Answers  






What is the alternate of 'Inheritance' ?

4 Answers   CybAge, HCL,


Explain importance of inheritance in java?

0 Answers  


Explain serialization and deserialization in java?

0 Answers  


Explain polymorphism citing an example.

0 Answers   Amazon,


How many times garbage collector will invoke an object?s finalize() method?

4 Answers  


What are parsers? Dom vs sax parser.

0 Answers  


What will be the output of round(3.7) and ceil(3.7)?

0 Answers  


Categories