搜索
首页Javajava教程Java中的CaseFormat类

Java中的CaseFormat类

Sep 08, 2023 am 10:25 AM
java编程caseformat

Java中的CaseFormat类

CaseFormat 类是一个实用程序类,用于在各种 ASCII 大小写格式之间进行转换 -

修饰符和类型 方法和描述
对象 clone()

重写 Cloneable。

boolean equals(Object obj )

覆盖等于。

字符串。 格式(双数字)

格式的特殊化。

抽象 StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) format(double number, StringBuffer toAppendTo, FieldPosition pos) p>

格式的特殊化。

字符串 格式(长数字)

格式的特殊化。

abstract StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos)格式的特殊化。

示例

现在让我们看一个实现 CaseFormat 的示例带有 java 文件 GuavaTester.java 的类 -

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

以上是Java中的CaseFormat类的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文转载于:tutorialspoint。如有侵权,请联系admin@php.cn删除

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SecLists

SecLists

SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境