Ad Code

المصفوفات Java 22- Arrays


المصفوفات Java 22- Arrays


import java.util.Arrays;
import java.util.Collections;

public class App{

/*  
    Arrays.toString(Object[] a) : String
    Arrays.deepToString(Object[] a) : String
    ----------------------------------------------------- 
    System.arraycopy(Object src,  int  srcPos, Object dest, int destPos, int length) : void
    ---------------------------------------
    Arrays.asList(T... a) : List<T>
    Collections.reverse(List<?> list) : void
    --------------------------------------
    Arrays.sort(int[] a) : void
    Arrays.sort(Integer[] a, Collections.reverseOrder()) : void
    */

  public static void main(String[] args) {
      int[] tab0= new int[]{2,3,5,1,4,7,0};
      System.out.println(Arrays.toString(tab0)); // [2,3,5,1,4,7,0]
      
      int[][] tab1=new tab1[][]{{2,5,3},{3},{7,0}};
      System.out.println(Arrays.deepToString(tab1)); //  [[2,5,3],[3],[7,0]]

      int[] destination= new int[10];
      System.arraycopy(tab0,  0, destination, 2, tab0.length);
      System.out.println(Arrays.toString(destination)); //  [0,0,2,3,5,1,4,7,0,0]

      Collections.reverse(Arrays.asList(tab0));
      System.out.println(Arrays.toString(tab0)); //  [0,1,2,3,4,5,7]

      Integer[] tab={3,5,1,5,8,6,7,0};
      Arrays.sort(tab, Collections.reverseOrder());
      System.out.println(Arrays.toString(tab)); //  [8,7,6,5,5,3,1,0]
      System.out.println( tab.length); //  8
  }
}

إرسال تعليق

0 تعليقات

Close Menu