更清洁的方法是
public static boolean isAnyStringNullOrEmpty(String... strings) { for (String s : strings) if (s == null || s.isEmpty()) return true; return false; }
然后你就可以这样称呼它
if (isAnyStringNullOrEmpty(firstname, lastname, amount, timespan, iban)) { Toast.makeText(MainActivity.this, "Oops, you forgot to fill in some fields!", Toast.LENGTH_SHORT).show(); } else { }