Arrays

Compare Two Java boolean Arrays Example

Want to learn quickly?
Try one of the many quizzes. More than Java 400 questions with detailed answers.

Add Comment

  • How i can sort alphabetically this merged two Arrays?plz

    String A[] = { “Joseph”,”Ariana”,”Xena”,”Rene”,”Peter”,”Diana”,”Rihanna”};

    String B[] = {“Madona”,”Diddy”,”Joe”,”Alice”};

    List<string> list = new ArrayList(Arrays.asList(A));
    list.addAll(Arrays.asList(B));
    Object[] C = list.toArray();
    System.out.println(Arrays.toString(C));
    }

    • String A[] = new String[] { “Joseph”, “Ariana”, “Xena”, “Rene”, “Peter”, “Diana”, “Rihanna”};
      String B[] = new String[] { “Madona”, “Diddy”, “Joe”, “Alice”};

      ArrayList<string> list = new ArrayList<string>();

      for(int i = 0; i < A.length; i++)
      list.add(A[i]);

      for(int i = 0; i < B.length; i++)
      list.add(B[i]);

      Collections.sort(list);

      for(String str : list)
      System.out.println(str);

Sponsors

Facebook Fans

Online Shopping – Flipkart