HashMap<String, String> map = new HashMap<>(); map.put("name", "Ivanov"); map.put("country", "Ukraine"); map.put("city", "Kiev"); map.put("age", null); StringBuilder result = new StringBuilder(); for (Map.Entry<String, String> entry : map.entrySet()) { if (!(entry.getValue() == null)){ result.append(String.format("%s = '%s' and ",entry.getKey(), entry.getValue())); } } System.out.println(result.substring(0, result.length() - 4).toString()); \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Вывод в консоль : country = 'Ukraine' and city = 'Kiev' and name = 'Ivanov' Вопрос такой: Почему пара name = 'Ivanov' вывелась последними? они ведь первыми были! Заранее спасибо!