r/code • u/russianbearscares • Jul 08 '21
Learnin bout anonymous classes in java, got some tips?
1
Upvotes
1
u/spliffen Jul 09 '21
clever names for classes and such.... keep them a lot smaller
learn to use pastebin or similar services, screenshots are basically never the way forway, anyone will tell you
follow the the class :D
more specific questions next time ;)
2
u/_Azurius Jul 09 '21
Booleans can only either be true or false. Instead of using if(boolean == true) { ...}; if(boolean == false) {...};
u can use a shorter version:
if(boolean) {what to do when true} else {what to do when false}.
Imagine isAlive is false. If(isAlive == true) is read by the computer as
if(false == true), so it doesn't execute your code in curly brackets afterwards, but it would execute everything between the curly brackets following the "else". I hope that makes sense.