Example usage for java.util Arrays toString

List of usage examples for java.util Arrays toString

Introduction

In this page you can find the example usage for java.util Arrays toString.

Prototype

public static String toString(Object[] a) 

Source Link

Document

Returns a string representation of the contents of the specified array.

Usage

From source file:Main.java

public static void main(String[] args) {

    // intializing an array arr1
    long[] arr1 = new long[] { 1L, 10L, 45L };

    System.out.println(Arrays.toString(arr1));

    // copying array arr1 to arr2 with newlength as 5
    long[] arr2 = Arrays.copyOf(arr1, 5);
    arr2[3] = 12L;//from   w w w .  jav a2 s .c o m
    arr2[4] = 123456789L;

    System.out.println(Arrays.toString(arr2));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String[] formatNames = ImageIO.getReaderFormatNames();
    System.out.println(Arrays.toString(formatNames));
}

From source file:Main.java

public static void main(String[] args) {

    // intializing an array arr1
    double[] arr1 = new double[] { 1.5, 3.5, 7.5 };

    System.out.println(Arrays.toString(arr1));

    // copying array arr1 to arr2 with range of index from 1 to 4
    double[] arr2 = Arrays.copyOfRange(arr1, 1, 4);

    System.out.println(Arrays.toString(arr2));
}

From source file:Main.java

public static void main(String[] args) {

    // initializing unsorted Object array
    Object ob[] = { 27, 11, 5, 44, 22, 0 };

    System.out.println(Arrays.toString(ob));

    // sorting array from index 1 to 3
    Arrays.sort(ob, 1, 3);/*from w  ww .  j  ava 2 s  .  c om*/

    System.out.println(Arrays.toString(ob));
}

From source file:Main.java

public static void main(String[] args) {

    // initializing float array
    float arr[] = new float[] { 1f, 2f, 3f, 4f, 5f };

    System.out.println(Arrays.toString(arr));

    // using fill for placing 12
    Arrays.fill(arr, 12f);/*from w ww .  j  a  va  2s . c  o  m*/

    System.out.println(Arrays.toString(arr));
}

From source file:Main.java

public static void main(String[] args) {

    // intializing an array arr1
    float[] arr1 = new float[] { 10f, 20f, 25f };

    System.out.println(Arrays.toString(arr1));

    // copying array arr1 to arr2 with newlength as 5
    float[] arr2 = Arrays.copyOf(arr1, 5);
    arr2[3] = 30f;/*from  w  w  w.ja  v  a2 s . c om*/
    arr2[4] = 40f;

    System.out.println(Arrays.toString(arr2));
}

From source file:Main.java

public static void main(String[] args) {

    // intializing an array arr1
    double[] arr1 = new double[] { 1.5, 2.5, 3.5 };

    System.out.println(Arrays.toString(arr1));

    // copying array arr1 to arr2 with newlength as 5
    double[] arr2 = Arrays.copyOf(arr1, 5);
    arr2[3] = 0.44;//from   w w  w . ja va  2s. c o m
    arr2[4] = 0.55;

    System.out.println(Arrays.toString(arr2));
}

From source file:Main.java

public static void main(String[] args) {
    String[] data = PLAYER.split("\\|\\|");
    System.out.println(Arrays.toString(data));
}

From source file:Main.java

public static void main(String[] args) {

    // initializing unsorted double array
    double dArr[] = { 13.2, 1.2, 0.7, 6.2, 4.5 };

    System.out.println(Arrays.toString(dArr));

    // sorting array
    Arrays.sort(dArr);/*from   www  .jav a 2s. c  om*/

    System.out.println(Arrays.toString(dArr));
}

From source file:Main.java

public static void main(String[] args) {

    // initializing unsorted double array
    double dArr[] = { 13.1, 1.4, 0.7, 1.5, 0.7 };

    System.out.println(Arrays.toString(dArr));

    // sorting array from index 0 to 3
    Arrays.sort(dArr, 0, 3);//from  w  ww.  j a  va  2  s. c  o  m

    System.out.println(Arrays.toString(dArr));
}