I got an Java ArrayIndexOutOfBoundsException when getting String input in Java. Please help me. This is my code: I edited my code to split using : it says
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at solution2.Solution.main(Solution.java:27)
public class Solution { static String search; public static void main(String[] args){ String[] fn,ln,tp; boolean[] isSet; Scanner sc=new Scanner(System.in); int no=sc.nextInt(); String[][] temp=new String[no][3]; fn=new String[no]; ln=new String[no]; tp=new String[no]; isSet=new boolean[no]; boolean flag=false; for(int i=0;i<no;i++){ temp[i]=sc.nextLine().split(":"); fn[i]=temp[i][0]; ln[i]=temp[i][1]; tp[i]=temp[i][2]; isSet[i]=true; } System.out.println(temp.length); search=sc.nextLine();