2ndchar
JCHJava Community | Help. Code. Learn.
•Created by 2ndchar on 4/4/2025 in #java-help
leetcode like problem? optimization of nesting tags

6 replies
JCHJava Community | Help. Code. Learn.
•Created by 2ndchar on 4/10/2024 in #java-help
reader.readLine() not working as expected
I have a sentences.txt with 60 lines of text.
I wanted it to print something along the lines of:
<div class="text" style="top: [THIS STARTS FROM 5 AND INCREMENTS BY 5, AND FOR EACH THREE INCREMENTS, THE INCREMENT DECREASES BY 1]ex;">[SENTENCE GOES HERE] [HOW MANY TIMES THIS HAS RUN GOES HERE]</div>
As an example, the first few lines should show:
<div class="text" style="top: 5ex;"> Lorem ipsum... 1</div>
<div class="text" style="top: 10ex;"> dolor sit amet... 2</div>
<div class="text" style="top: 15ex;"> adipscicing ameold.. 3</div>
<div class="text" style="top: 19ex;"> molor alor... 4</div>
...
<div class="text" style="top: ??ex;"> blablabla... ?<60</div>
To my confusion, the result looks like:
...
<div class="text" style="top: 2694ex;">Curabitur rutrum... 899</div>
<div class="text" style="top: 2695ex;">Curabitur rutrum... 900</div>
Not only did reader.readLine() seem to read the same line (not shown, but it does this every 16~ times), and the top:??ex and number at the end seems to vastly exceed what I thought should have resulted from the for loop
10 replies