Hi Abdul,
Sorry for answering so late.
# out.print(String.format(ATTR_TEMPLATE,"name",this.name));
# out.print(String.format(ATTR_TEMPLATE,"size",this.size));
String.format() is basically used to replace complex String concatenation.
Instead of writing:
This complex String concatenation uses nesting of double quotes (") and single quotes (');
This can be eliminated by declaring constants.
and then using these constants.
The following code achieves the same result as that of complex nesting of double and single quotes.
The above code is a lot more pretty and readable.
This is particularly useful when we have multiple occurrences of the same attribute that requires nesting of double and single quotes.
Hope I answered your question.
Best Regards