0

I am inserting a key value pair to hashmap in the below code.

HashMap<String, String> result = new HashMap<String, String>();
    result.put("Description", "true";
    result.put("System Menu Program", "false");
    result.put("User ID Code", "false");
    result.put("User ID Version", "true");

And i am trying to iterate the result to be printed by joining multiple output string . currently i am using String.join to join the results which contains false as value but the problem i am facing here is i need to use any alternate to String.join because String.join method has been released in java 1.8 but our server is using 1.6 is there a alternate way to replace this below function

List<String> a1 = new ArrayList<String>();
    for (String key : result.keySet()) {
       if (result.get(key).contains("false")){
           a1.add(result.get(key));
           finalResult = String.join(" // ", a1 );
       }
    }
    System.out.println(finalResult);
    return finalResult;
Santhosh Siddappa
  • 708
  • 3
  • 14
  • 29

1 Answers1

0

Take a look at Apache common's StringUtils.join, which internally iterates and concatenate.

Alternatively, have your own implementation that will iterate and join.

sidgate
  • 14,650
  • 11
  • 68
  • 119