CaseFormat Class | Guava | Java
Last Updated :
15 Nov, 2018
CaseFormat is a utility class for converting between various ASCII case formats. Behavior is undefined for non-ASCII input.
Declaration: The declaration for com.google.common.base.CaseFormat is as:
@GwtCompatible
public enum CaseFormat
extends Enum
Below table gives the summary of Enum Constants and their description:
Below table gives the summary of methods of CaseFormat class and their description:
Example 1:
import com.google.common.base.CaseFormat;
class GFG {
public static void main(String args[])
{
String str = "geeks_for_geeks" ;
System.out.println( "Original String: "
+ str);
System.out.println( "Lower Camel Format: "
+ CaseFormat
.LOWER_UNDERSCORE
.to(CaseFormat
.LOWER_CAMEL,
str));
System.out.println( "Upper Camel Format: "
+ CaseFormat
.UPPER_UNDERSCORE
.to(CaseFormat
.UPPER_CAMEL,
str));
}
}
|
Output:
Original String: geeks_for_geeks
Lower Camel Format: geeksForGeeks
Upper Camel Format: GeeksForGeeks
Example 2:
import com.google.common.base.CaseFormat;
import java.util.*;
class GFG {
public static void main(String args[])
{
System.out.println( "The Enum constants "
+ "of CaseFormat Class are:\n"
+ Arrays
.toString(CaseFormat
.values()));
}
}
|
Output:
The Enum constants of CaseFormat Class are:
[LOWER_HYPHEN, LOWER_UNDERSCORE, LOWER_CAMEL, UPPER_CAMEL, UPPER_UNDERSCORE]
Reference: Google Guava
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...