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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started