Question: How do I test a HashMap in main()? public static void asNestedObject1( HashMap index, Writer writer, int level) throws IOException { { if (index.isEmpty()) {
How do I test a HashMap
public static void asNestedObject1(HashMap
Writer writer, int level) throws IOException {
{
if(index.isEmpty()) {
try {
writer.write("{" + System.lineSeparator() + "}");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
int count = 0;
writer.write("{");
writer.write(System.lineSeparator());
for(Entry
indent(level + 1, writer);
quote(entry.getKey(), writer);
writer.write(": ");
//indent(level, writer);
asArray1(entry.getValue(), writer, level + 1);
if(count < index.size() -1 ) {
writer.write(",");
writer.write(System.lineSeparator());
}
count++;
}
writer.write(System.lineSeparator());
writer.write("}");
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
