I realized there could be a lot of bad code in a system while writing Java.
I wonder why schools don't teach what programming practices are bad. For example, in Java, using a big try/catch block that catches Exception is bad, but no one told me. And we see the typical "String + String" concatenation appear in every corner of a program.
Isn't it the job of schools, assuming most programmers are taught at a school and not self-taught, to warn students away from the pitfalls in a programming?
Exceptionis usually not the best solution, but I wouldn't call it categorically bad. And the typical "String + String" concatenation makes the code easy to read, so most of the time it is best practice. Except when called many many times in a tight loop, where it may indeed degrade performance. Similarly, all idioms / techniques have their benefits and drawbacks, and they are applicable for some problems but bad for others. These details can only reliably be learnt during practice, as and when you actually need them.