Splitter Class | Guava | Java Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Guava's Splitter Class provides various methods to handle splitting operations on string, objects, etc. It extracts non-overlapping substrings from an input string, typically by recognizing appearances of a separator sequence. This separator can be specified as a single character, fixed string, regular expression or CharMatcher instance. Declaration: Following is the declaration for com.google.common.base.Splitter class: @GwtCompatible(emulated = true) public final class Splitter extends Object The following table gives a brief summary about the methods of Guava's Splitter class: Example: Java // Java code to show implementation of // Guava's Splitter class's method import com.google.common.base.Splitter; class GFG { // Driver's code public static void main(String[] args) { // Splitter.on(char separator) returns a splitter // that uses the given single-character separator. // Splitter omitEmptyStrings() omits empty // strings from the results. System.out.println(Splitter.on(',') .trimResults() .omitEmptyStrings() .split("GeeksforGeeks ,is, the, best, website, to, prepare, for, interviews")); } } Output: [GeeksforGeeks, is, the, best, website, to, prepare, for, interviews] Some other methods provided by the Splitter class are: Example: Java // Java code to show implementation of // Guava's Splitter class's method import com.google.common.base.Splitter; import java.util.List; class GFG { // Driver's code public static void main(String[] args) { // A string variable named str String str= "Hello, GFG, What's up ?"; // SplitToList returns a List of the strings. // This can be transformed to an ArrayList or // used directly in a loop. List<String> myList = Splitter.on(',').splitToList(str); for (String ele : myList) { System.out.println(ele); } } } Output: Hello GFG What's up ? Reference: Google Guava Comment More infoAdvertise with us Next Article Joiner class | Guava | Java S Sahil_Bansall Follow Improve Article Tags : Java java-guava Guava-Splitter Practice Tags : Java Similar Reads Joiner class | Guava | Java Guava's Joiner class provides various methods to handle joining operations on string, objects, etc. This class provides advanced functionality for the join operation. Declaration: Following is the declaration for com.google.common.base.Joiner class : @GwtCompatible public class Joiner extends Object 2 min read Joiner class | Guava | Java Guava's Joiner class provides various methods to handle joining operations on string, objects, etc. This class provides advanced functionality for the join operation. Declaration: Following is the declaration for com.google.common.base.Joiner class : @GwtCompatible public class Joiner extends Object 2 min read Shorts Class | Guava | Java Shorts is a utility class for primitive type short. It provides Static utility methods pertaining to short primitives, that are not already found in either Short or Arrays. Declaration : @GwtCompatible(emulated=true) public final class Shorts extends Object Below table shows the Field summary for Gu 3 min read Longs Class | Guava | Java Longs is a utility class for primitive type long. It provides Static utility methods pertaining to long primitives, that are not already found in either Long or Arrays. Declaration : @GwtCompatible(emulated=true) public final class Longs extends Object Below table shows the Field summary for Guava L 3 min read Range Class | Guava | Java Guavaâs Range represents an interval, for example, a < range < b. Here range includes any value between a and b, called endpoints which form the boundary. Any value between the boundary is a contiguous span of values of type Comparable. Declaration : The declaration for com.google.common.colle 5 min read Ordering Class | Guava | Java A comparator, with additional methods to support common operations. This is an "enriched" version of Comparator. The common ways to get an instance of Ordering are : Subclass it and implement compare(T, T) instead of implementing Comparator directly. Pass a pre-existing Comparator instance to from(C 4 min read Like