tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Tools and Libs > Google Guava > Collections > String to Char List

String to Char List 

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 Lists.charactersOf() API. It returns a view of the specified string as an immutable list of Characters.

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

import java.util.List;

import com.google.common.collect.Lists;

public class StringtoCharListTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    List<Character> charList = Lists.charactersOf("BE THE CODER");
    System.out.println(charList);
  }

}
   

It gives the following output,
[B, E,  , T, H, E,  , C, O, D, E, R]



 
  


  
bl  br