JAVA:java.lang.NumberFormatException:对于输入字符串:" [123,456]" [英] JAVA: java.lang.NumberFormatException: For input string: "[123, 456]"

查看:79
本文介绍了JAVA:java.lang.NumberFormatException:对于输入字符串:" [123,456]"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人请帮我解决这个案子。当我尝试运行此代码时,我得到了像标题一样的java错误:



Somebody please help me about this case. i got java error like the title when i try run this code:

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class test {

	static List<String> skill = new ArrayList<String>();//this must be String
	
	public static void main(String[] args) {
		skill.add("1:123 456");//input value cannot change
		System.out.println(getSkills());
	}
	
	public static List<StigmaSkill> getSkills() {
		List<StigmaSkill> list = new ArrayList<StigmaSkill>();
		
		for (String st : skill) {
			String[] array = st.split(":");
			int aInt = Integer.parseInt(Arrays.deepToString(array[1].split("\\s+")));
			list.add(new StigmaSkill(aInt));
		}
		return list;//return from string to integer value
	}
	
	private static class StigmaSkill {
		
		private int skillId;
		
		public StigmaSkill(int skillId) {
			this.skillId = skillId;
		}

		public int getSkillId() {
			return this.skillId;
		}
	}
}





请帮我弄清楚并解决我的问题。提前谢谢



Please help me figure out and solve my problem. thanks in advance

推荐答案

请不要重新发布相同的问题。您已在原始帖子中获得了一些建议。
Please do not repost the same question. You have already been given some suggestions in your original post.


这篇关于JAVA:java.lang.NumberFormatException:对于输入字符串:&quot; [123,456]&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆