Sometimes conditions can become quite complex, so for readability I usually split them up and give each component a meaningful name. This defeats short-circuit evaluation ho
You can use early returns (from a method) to achieve the same effect:
[Some fixes applied]
public static boolean areArgsOk(String[] args) {
if(args == null)
return false;
if(args.length != 2)
return false;
if(args[0].equals(args[1]))
return false;
return true;
}
public static void main2(String[] args) {
boolean b = areArgsOk(args);
if(b)
System.out.println("Args are ok");
}