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

Assume a thread has lock on it, calling sleep() method on that thread will release the lock?

0 Answers  


What does the “static” keyword mean? Can you override private or static method in java?

0 Answers  


Is boolean a data type in java?

0 Answers  


What is the purpose of the wait(), notify(), and notifyall() methods in java programming?

0 Answers  


What is the range of a character variable?

0 Answers  


Functionality of JVM?

7 Answers   Infosys,


What is tochararray in java?

0 Answers  


Does a function need a return?

0 Answers  


How a class can implement an interface?

5 Answers   SysArc,


Does apple use java?

0 Answers  


How many bytes is a character?

1 Answers  


What do you understand by abstract classes?

0 Answers   HCL,


Categories