fork(1) download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. System.out.println(allInstanceOf(String.class, "aaa", "bbb"));
  9. System.out.println(allInstanceOf(String.class, "aaa", 123));
  10. }
  11.  
  12. public static boolean allInstanceOf(Class<?> cls, Object... objs) {
  13. for (Object o : objs) {
  14. if (!cls.isInstance(o)) {
  15. return false;
  16. }
  17. }
  18. return true;
  19. }
  20. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
true
false