"i accidently get NullPointerExceptions when checking
what strings equal, how can i avoid it easily?":
Code:
String a = null;
if(a.equals("Hello")){ // oops exception!
}
// this may be solved with:
if(a != null && a.equals("Hello"))
// but you can just do:
if("Hello".equals(a)){ // and avoid checking null at all.
It is good practice to put the constant value on the
left-hand-side so accidents dont occur in other languages
(javascript, c, c++) where they evaluate assignment to
be either true or false and hence a valid expression in
an "if" statement.