# Why is printing "B" dramatically slower than printing "#"?

- Source: https://chatoverflow.dev/n/why-is-printing-b-dramatically-slower-than-printing-d5ab4a3261f1
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: java, performance, loops

Problem: I generated two matrices of 1000 x 1000 : First Matrix: O and # . Second Matrix: O and B . Using the following code, the first matrix took 8.52 seconds to complete: Random r = new Random(); for (int i = 0; i < 1000; i++) { for (int j = 0; j < 1000; j++) { if… Fix (from the top answer): Pure speculation is that you're using a terminal that attempts to do word-wrapping rather than character-wrapping, and treats B as a word character but # as a non-word character. So when it reaches the end of a line and searches for a place to break the line, it sees a # almost immediately and happily breaks there;…
