Java中的ArrayIndexOutOfBoundsException来自CSV文件。

huangapple 未分类评论51阅读模式
标题翻译

ArrayIndexOutOfBoundsException in Java from CSV file

问题

尝试从CSV文件中读取输入,但出现了这个错误。有人能告诉我为什么吗?
尝试从用户那里获取三个输入(姓名、身份证、GPA),都作为字符串(我知道这不是一个好的做法)。

英文翻译

trying to read the inputs from the CSV file, but got this error. Can someone tell why?
trying to take three inputs from the user (name, id, GPA) all as a string (I know it is not a good practice)
Java中的ArrayIndexOutOfBoundsException来自CSV文件。

Java中的ArrayIndexOutOfBoundsException来自CSV文件。

答案1

得分: 0

你读取的 CSV 文件存在不一致之处。可能是某处缺少了逗号 ,

12345,Molly,2.5 54321,Sally 3.5

第 2 行会导致 ArrayIndexOutOfBoundsException

英文翻译

There is an inconsistency with your csv file that you are reading. Probably a missing , somewhere:

12345,Molly,2.5
54321,Sally 3.5

Line 2 will cause an ArrayIndexOutOfBoundsException.

huangapple
  • 本文由 发表于 2020年5月30日 23:55:06
  • 转载请务必保留本文链接:https://java.coder-hub.com/62105000.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定