1. Learn
  2. /
  3. Courses
  4. /
  5. Optimizing Code in Java

Connected

Exercise

Implementing memory-efficient string processing

You're developing a text processing application that needs to pre-populate an array with the same string value multiple times. The current implementation creates a new String object in each loop iteration, which is inefficient for large arrays. Your task is to implement a more efficient version of this method.

Instructions

100 XP
  • Reuse the provided value to add to the list.
  • Return the final array.