Решил как то по колхозному мне кажется, подскажите что в первую очередь можно оптимизировать? public class Solution { public static volatile List<Person> allPeople = new ArrayList<Person>(); static { allPeople.add(Person.createMale("Иванов Иван", new Date())); //сегодня родился id=0 allPeople.add(Person.createMale("Петров Петр", new Date())); //сегодня родился id=1 } public static void main(String[] args) throws ParseException { switch(args[0]){ case("-c"): synchronized (allPeople){ addPerson(args); } break; case("-u"): synchronized (allPeople){ upgrade(args); } break; case("-d"): synchronized (allPeople) { delete(args); } break; case("-i"): synchronized (allPeople){ info(args); } break; } } public static void addPerson(String... arg) throws ParseException { for(int i=1; i<arg.length;){ Date dat = new SimpleDateFormat("dd/MM/yyyy",Locale.ENGLISH).parse(arg[i+2]); if(arg[i+1].equals("м")) allPeople.add(Person.createMale(arg[i],dat)); if(arg[i+1].equals("ж")) allPeople.add(Person.createFemale(arg[i],dat)); //System.out.println(allPeople.get(allPeople.size()-1).getName()+allPeople.get(allPeople.size()-1).getSex()+allPeople.get(allPeople.size()-1).getBirthDate()); System.out.println(allPeople.size()-1); if(i<=arg.length-3) i=i+3; else break; } } public static void upgrade(String... arg) throws ParseException { for(int i=1; i<arg.length;){ Person p = allPeople.get(Integer.parseInt(arg[i])); Date dat = new SimpleDateFormat("dd/MM/yyyy",Locale.ENGLISH).parse(arg[i+3]); p.setName(arg[i+1]); p.setBirthDate(dat); if(arg[i+2].equals("м")) p.setSex(Sex.MALE); if(arg[i+2].equals("ж")) p.setSex(Sex.FEMALE); if (i<arg.length-4) i=i+4; else break; } } public static void delete(String... arg) { for(int i=1; i<arg.length;i++){ Person p = allPeople.get(Integer.parseInt(arg[i])); p.setSex(null); p.setName(null); p.setBirthDate(null); } } public static void info(String... arg) { for(int i=1; i<arg.length; i++){ Person p = allPeople.get(Integer.parseInt(arg[i])); SimpleDateFormat formatOut = new SimpleDateFormat("dd-MMM-yyyy",Locale.ENGLISH); if(p.getSex().equals(Sex.MALE)) System.out.println(p.getName()+" м "+ formatOut.format(p.getBirthDate())); if(p.getSex().equals(Sex.FEMALE)) System.out.println(p.getName()+" ж "+ formatOut.format(p.getBirthDate())); } } }