DEV Community

Discussion on: What's the Worst Code You've Ever Seen or Written?

Collapse
 
renegadecoder94 profile image
Jeremy Grifski • Edited

I teach a Java class, and students often gravitate toward strings because of their functionality. Why try to get the third digit from a number using math (i.e. (5092 / 10) % 10) when you can convert it to a string and call the index method on it (i.e. Integer.toString(5092).charAt(3))?

Not making an excuse for this code! It's bad, but I can see why people do it. haha In this case, it really makes no sense.