Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use CharUtil, the simple utility class of Char in Java

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use CharUtil, the simple tool class of Char in Java, which is very detailed and has certain reference value. Friends who are interested must finish reading it!

One of the basic data types of char,java, which holds two-byte int integers. The default display is the character of Unicode, the int integer index position. I won't explain the details in detail.

Version 1: the following queries whether numbers, letters, uppercase and lowercase letters, get the int representation of characters.

Although simple, it also means that it can be enhanced.

Package cn.util;/** * character utility class: some simple methods of operation. * * @ author jxlys @ version1.0 * / public class CharUtil {/ * returns the int value corresponding to the character. * * @ param c * / public static int getInt (char c) {return (int) c;} / * detect whether the letter * * @ param c * @ return * / public static boolean isLetterCharacter (char c) {return isUpperCharacter (c) | | isLowerCharacter (c)? True: false;} / * detect capital * * @ param c * / public static boolean isLowerCharacter (char c) {return (c > = 97 & & c)

< 123) ? true : false; } /** * 检测是否数字. * * @param c */ public static boolean isNumber(char c) { return c >

= 48 & c

< 58 ? true : false; } /** * 检测小写. * * @param c */ public static boolean isUpperCharacter(char c) { return (c >

= 65 & & c < 91)? True: false;} private CharUtil () {/ / the constructor throw new RuntimeException () is not allowed;}} above is all the content of this article entitled "how to use CharUtil, a simple utility class for Char in Java". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report