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; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)