Less Code with Ternary Operator #java #shorts #coding #airhacks

preview_player
Показать описание

Java used in this short: openjdk version "21" 2023-09-19 LTS

#airhacks
Рекомендации по теме
Комментарии
Автор

Which compiler /app do you use for java coding?

animeeditz
Автор

Well, ternary can be ugly / hard to read... Java needs "if" and "try" expressions where you get best of both worlds - readability and conciseness.

roktitovsek
Автор

For better code reading I wouldn’t recommend it

sxboson
Автор

Well, who does not do that?
To use less characters, you could actually have
out.println("This was " + (!success ? "not " : "") + "successful");

DanielWamara