Java中的CaseFormat类
CaseFormat类是用于在各种ASCII大小写格式之间进行转换的实用程序类-
覆盖Cloneable。
重写equals。
格式的专业化。
格式的特殊化。
格式的专业化。
格式的特殊化。
示例
现在让我们看一个使用Java文件GuavaTester.java实现CaseFormat类的示例-
import com.google.common.base.CaseFormat;
public class GuavaTester {
public static void main(String args[]) {
GuavaTester tester = new GuavaTester();
tester.testCaseFormat();
}
private void testCaseFormat() {
String data = "test_data";
System.out.println(CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, "test-data"));
System.out.println(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "test_data"));
System.out.println(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, "test_data"));
}
}使用javac编译器编译类,如下所示:
C:\Guava>javac GuavaTester.java
现在运行GuavaTester以查看结果-
C:\Guava>java GuavaTester
输出结果
这将产生以下输出-
testData testData TestData
热门推荐
10 五一公司放假祝福语简短
11 追星女孩的祝福语简短
12 给长辈端午祝福语 简短
13 生日祝福语有诗意简短
14 团圆日祝福语简短
15 中秋商务祝福语简短最新
16 温暖文艺简短祝福语短句
17 男孩上学祝福语简短的
18 入住酒店文案祝福语简短