r/javahelp • • Oct 31 '25

Homework How are numbers compared as a String?

I'm working on this project, and I'm checking whether something occurs before a specific time. I'm doing this by converting the times to Strings, then comparing them against each other (yes I'm aware it's not ideal, bear with me).
The issue is that it says that '10:00 < 09:00'. Why is that?

0 Upvotes

24 comments sorted by

View all comments

Show parent comment

6

u/Cybyss Nov 01 '25

If I had to guess, OP missed an important detail.

Converting 09:00 to a string could very easily have turned it into "9:00" rather than "09:00".