Home > Java > javaTutorial > CaseFormat class in Java

CaseFormat class in Java

王林
Release: 2023-09-08 10:25:02
forward
962 people have browsed it

CaseFormat class in Java

The CaseFormat class is a utility class for converting between various ASCII case formats -

##Abstract StringBufferformat(double number, StringBuffer toAppendTo, FieldPosition pos)format(double number, StringBuffer toAppendTo , Specialization of FieldPosition pos)StringFormat (long number)Specialization of the abstract StringBufferformat(long number, StringBuffer toAppendTo, FieldPosition pos)
Modification Symbol and type Method and description
Object clone()

Override Cloneable.

boolean equals(Object obj)

Override equals.

String. Format (Double Number)

Specialization of format.

p> format.

format.

Specialization of the format.

Example

Now let us see an example of a class that implements CaseFormat with the java file 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"));
   }
}

Copy after login

Compile the class using javac compiler as follows-

C:\Guava>javac GuavaTester.java
Copy after login

Now run GuavaTester to see the results-

C:\Guava>java GuavaTester
Copy after login

Output

This will produce the following output-

testData
testData
TestData
Copy after login

The above is the detailed content of CaseFormat class in Java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template