VOOZH about

URL: https://www.geeksforgeeks.org/java/splitter-withkeyvalueseparatorchar-separator-method-guava-java/

⇱ Splitter withKeyValueSeparator(char separator) method | Guava | Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Splitter withKeyValueSeparator(char separator) method | Guava | Java

Last Updated : 11 Jul, 2025
The withKeyValueSeparator(char separator) method of Guava's Splitter Class accepts a mandatory parameter separator and splits entries into keys and values using this separator. Syntax:
public Splitter.MapSplitter withKeyValueSeparator(char separator)
Parameters: The method accepts a parameter separator and splits entries into keys and values using this separator. Return Value: The method returns a MapSplitter which splits entries based on this splitter. Note: We pass the separator within pairs to this method. The on() method receives the separator between pairs of keys and values. Below examples illustrate the implementation of withKeyValueSeparator() method of Guava's Splitter class: Example 1:
Output:
Data Structures -> Coding
Sports -> Football
Capital -> Delhi
Example 2:
Output:
First -> I
Second -> II
Third -> III
Fourth -> IV
Comment