tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Collections > Object Arrays Prepend

Object Arrays Prepend 

Google Guava is a java library with lot of utilities and reusable components. This requires the library guava-10.0.jar to be in classpath. The following example shows using ObjectArrays.concat() API. It returns a new array by prepending the new element as first element in the array.

File Name  :  
com/bethecoder/tutorials/guava/collection_tests/ObjectArraysPrependTest.java 
Author  :  Sudhakar KV
Email  :  [email protected]
   
package com.bethecoder.tutorials.guava.collection_tests;

import java.util.Arrays;

import com.google.common.collect.ObjectArrays;

public class ObjectArraysPrependTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    Integer [] first = new Integer [] { 24};
    Integer [] result = ObjectArrays.concat(1729, first);
    System.out.println(Arrays.toString(result"  length : " + result.length);
  }

}
   

It gives the following output,
[1729, 2, 4, 6]  length : 4



 
  


  
bl  br