Java - putting comma separated integers from a text file into an array
问题 Had a quick question based on an assignment I'm working on. I have a list of numbers like this in a text file: 5, 8, 14 7, 4, 2 And I need them inserted into an array as such joe[5][8] = 14; joe[7][4] = 2; Having trouble getting this done, thanks to anyone who can give me a hand. -Edit- This is the code I have now File f = new File("solution.txt"); Scanner sc = new Scanner(f); while(sc.hasNextLine()) { if(sc.hasNextInt()) x = sc.nextInt(); if(sc.hasNextInt()) y = sc.nextInt(); if(sc