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 Append

Object Arrays Append 

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 appending the new element as last element in the array.

File Name  :  
com/bethecoder/tutorials/guava/collection_tests/ObjectArraysAppendTest.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 ObjectArraysAppendTest {

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

}
   

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



 
  


  
bl  br