New drivers licence question from code coach
Can i please know why am i getting an array out of bound exception here : import java.util.*; public class Program { public static void main(String[] args) { Scanner ip = new Scanner(System.in); String n=ip.nextLine(); int a=ip.nextInt(); String on=ip.nextLine(); String [] ons=new String[5]; ons=on.split(" "); ons[4]=n; for(int i=0;i<5;i++) { for(int j=i+1;j<5;j++) { String temp; if(ons[i].compareTo(ons[j])>0) { temp=ons[i]; ons[i]=ons[j]; ons[j]=temp; } } } for(int i=0;i<5;i++) { if(ons[i].equals(n)) System.out.print(((i+1)*20)/a); } } }