Botre Posted April 20, 2015 Share Posted April 20, 2015 Beginners swag. public static int getMyTotalLevel(Script script) { int total = 0; for (Skill skill : Skill.values()) total += script.getSkills().getStatic(skill); return total; } Quote Link to comment Share on other sites More sharing options...
lare96 Posted April 27, 2015 Share Posted April 27, 2015 Could always use Streams introduced in Java 8 to make this a one liner. public static int getMyTotalLevel(Script script) { return Arrays.stream(Skill.values()).mapToInt(script.getSkills()::getStatic).sum(); } Quote Link to comment Share on other sites More sharing options...
Botre Posted April 27, 2015 Author Share Posted April 27, 2015 Could always use Streams introduced in Java 8 to make this a one liner. public static int getMyTotalLevel(Script script) { return Arrays.stream(Skill.values()).mapToInt(script.getSkills()::getStatic).sum(); } Not sure if it's worth it but sure. Quote Link to comment Share on other sites More sharing options...