Google Guava Joiner Example
import java.util.Arrays;
import com.google.common.base.Joiner;
public class JoinerTest {
public static void main(String[] args) {
System.out.println("Joiner Use With String");
System.out.println(Joiner.on(":").join("java","proficiency"));
System.out.println("Joiner Use With List");
System.out.println(Joiner.on("+").join(Arrays.asList(10,20,30)));
}
}
Output:
Joiner Use With String
java:proficiency
Joiner Use With List
10+20+30
import java.util.Arrays;
import com.google.common.base.Joiner;
public class JoinerTest {
public static void main(String[] args) {
System.out.println("Joiner Use With String");
System.out.println(Joiner.on(":").join("java","proficiency"));
System.out.println("Joiner Use With List");
System.out.println(Joiner.on("+").join(Arrays.asList(10,20,30)));
}
}
Output:
Joiner Use With String
java:proficiency
Joiner Use With List
10+20+30
No comments:
Post a Comment