Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Duplicate in string
//Title of this code //'main' method must be in a class 'Rextester'. public class Rextester { public void printTwoMaxNumbers(int[] nums){ int maxOne = 0; int maxTwo = 0; for(int n:nums){ if(maxOne < n){ maxTwo = maxOne; maxOne =n; } else if(maxTwo < n){ maxTwo = n; } } System.out.println("First Max Number: "+maxOne); System.out.println("Second Max Number: "+maxTwo); } public static void main(String a[]){ int num[] = {5,34,78,2,45,1,99,23}; Rextester tmn = new Rextester(); tmn.printTwoMaxNumbers(num); } }
run
|
edit
|
history
|
help
0
1 e
jb12.0 threads.enums
forloop1
bubble sort
mp1
Problem: on_off
pow x^n
Abhay
Zombie virus
Rextester.java