title: StringBuffer.append() vs ArrayList<String>.add()
body: <p>In terms of performance and memory, which would be the most efficient?</p>
  
  <p>Right now, I have a <code>List&lt;ArrayList&lt;String&gt;&gt;</code> that holds almost 200,000 records, generated by a separate business logic. I am trying to print it in a table format in a HTML page using Thymeleaf.
  Currently, I am using nested <code>th:each</code> loop to print the data with <code>th:text</code>. As expected, this takes a long time.</p>
  
  <p>I looked into <a href="https://stackoverflow.com/questions/31892290/adding-html-tags-using-thtext-in-thymeleaf?rq=1">this</a> and found that <code>th:utext</code> can be used to print html content in Thymeleaf. </p>
  
  <p>My business logic to generate these 200,000 records, currently gives a <code>List&lt;ArrayList&lt;String&gt;&gt;</code> object, but I can modify it to a <code>List&lt;String&gt;</code> object by making changes.</p>
  
  <p>My question, however, is that, will that be more memory-efficient. It is very much possible that it will be more performance efficient, but my main concern is memory-efficiency. Would a <code>List&lt;ArrayList&lt;String&gt;&gt;</code> take up the same amount of memory as a <code>List&lt;String&gt;</code> containing the same data ? (By same data, I mean, the content is the same - instead of an <code>ArrayList&lt;String&gt;</code>, it's going to contain a single string with HTML elements in between). Or would it take up more memory?</p>
  
  <p>I am relatively new to understanding space complexity of data structures; hence the query.</p>