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) {
    FloatBuffer floatBuffer = FloatBuffer.allocate(10);

    floatBuffer.put(new float[] { 1.23F, 2.13F, 3.13F, 2.13F, }, 0, 2);

    System.out.println(Arrays.toString(floatBuffer.array()));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    byte[] ipAddr = new byte[] { 127, 0, 0, 1 };
    InetAddress addr = InetAddress.getByAddress("Localhost", ipAddr);
    System.out.println(Arrays.toString(addr.getAddress()));
}

From source file:Main.java

public static void main(String[] args) {
    Integer[] arr = { 1, 2, 3, 1, 4, 4, 1, 5 };
    System.out.println(Arrays.toString(arr));
    List<Integer> l = Arrays.asList(arr);

    System.out.println(l);/*  ww w .j av a 2  s.  co  m*/

    Set<Integer> set = new HashSet<Integer>();
    for (int j = 0; j < l.size(); j++) {
        if (Collections.frequency(l, l.get(j)) > 1) {
            set.add(l.get(j));
        }
    }
    System.out.println("dups are:" + set);
}

From source file:Main.java

public static void main(String[] args) {
    Integer[] numbers = { 1, 2, 3 };

    // watch return types, it is implied, no return keyword is necessary
    Arrays.sort(numbers, (i1, i2) -> i2 - i1);

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

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String testStr = "J J@H.com";
    System.out.println("Original string: " + testStr);
    String[] result = testStr.split("[\\W && [^.@]]+");
    System.out.println(Arrays.toString(result));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    byte[] bytes = new byte[10];
    ByteBuffer buf = ByteBuffer.allocate(10);
    buf = ByteBuffer.wrap(bytes);

    System.out.println(Arrays.toString(buf.array()));
    System.out.println(buf.toString());
}

From source file:Main.java

public static void main(String[] args) {
    List<Integer> numberList = Arrays.asList(1, 2, 3, 4, 5);
    Stream<Integer> listStream = numberList.stream();

    System.out.println(Arrays.toString(listStream.toArray()));
}

From source file:Main.java

public static void main(String[] args) {

    // initializing unsorted short array
    Short[] sArr = new Short[] { 3, 13, 1, 9, 21 };

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

    // create a comparator
    Comparator<Short> comp = Collections.reverseOrder();

    // sorting array with reverse order using comparator
    Arrays.sort(sArr, comp);/*from   w  w w .j a v  a2s . com*/

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

From source file:Main.java

public static void main(String[] args) {

    // initializing unsorted short array
    Short sArr[] = new Short[] { 3, 13, 1, 9, 21 };

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

    // create a comparator
    Comparator<Short> comp = Collections.reverseOrder();

    // sorting array with reverse order using comparator from 0 to 2
    Arrays.sort(sArr, 0, 2, comp);

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

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(50);
    cb1.append("java2s.com");
    cb1.rewind();//from w w  w.  j  ava 2 s.  co m

    System.out.println(cb1.charAt(2));
    System.out.println(Arrays.toString(cb1.array()));

}