import java.util.List;
import java.util.ArrayList;
public class TextBlockPrinter {
public static void printTextBlocks(List<String> textBlocks) {
if (textBlocks == null || textBlocks.isEmpty()) {
System.out.println("No text blocks to print.");
return;
}
for (int i = 0; i < textBlocks.size(); i++) {
String textBlock = textBlocks.get(i);
System.out.println("--- Text Block " + (i + 1) + " ---");
System.out.println(textBlock);
System.out.println("--------------------------");
}
}
public static void main(String[] args) {
// Example usage
List<String> blocks = new ArrayList<>();
blocks.add("This is the first text block.\nIt contains multiple lines.");
blocks.add("Here's the second block.\nIt's shorter.");
blocks.add("A longer text block to demonstrate the printing.");
printTextBlocks(blocks);
}
}
Add your comment