-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsechigh.java
More file actions
47 lines (28 loc) · 712 Bytes
/
Copy pathsechigh.java
File metadata and controls
47 lines (28 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package sample;
import java.util.*;
import java.lang.*;
import java.io.*;
public class sechigh {
public static void main (String[] args) throws java.lang.Exception
{
int a[]={3,4,5,6,7,9,2,10};
int high,sec;
if(a[0]>a[1]){
high=a[0];
sec=a[1];
}else{
high=a[1];
sec=a[0];
}
for(int i=2;i<a.length;i++){
if(a[i]>high){
sec=high;
high=a[i];
}
else if(a[i]>sec && a[i]!=high){
sec=a[i];
}
}
System.out.println(sec);
}
}