tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Primitives > Integers Join

Integers Join 

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 Ints.join() API. It joins the given integers with provided string separator.

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

import com.google.common.primitives.Ints;

public class IntJoinTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    String str = Ints.join("."123456);
    System.out.println(str);
    
    str = Ints.join("+"123456);
    System.out.println(str);
    
    str = Ints.join("-+-"123456);
    System.out.println(str);
  }
}
   

It gives the following output,
1.2.3.4.5.6
1+2+3+4+5+6
1-+-2-+-3-+-4-+-5-+-6



 
  


  
bl  br