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 judge the number of characters of each type by java

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces java how to judge the number of various types of characters, has a certain reference value, interested friends can refer to, I hope you read this article after a great harvest, the following let Xiaobian take you to understand.

described

input a line of character string, and count that number of English letters, spaces, number and other characters respectively

Input Description:

console randomly enters a string

Output Description:

Output the number of English letters, numbers, spaces and other characters contained in the string (format: English letters x numbers x spaces x other x). Output has been given in the preset code.

import java.util.Scanner; public class Main { public static void main(String[] args) { int numbers = 0; int words = 0; int space = 0; int other = 0; Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); //write your code here...... System.out.println("English letters"+words+"numbers"+numbers+"spaces"+space+"others"+other); }}import java.util.Scanner; public class Main { public static void main(String[] args) { int numbers = 0; int words = 0; int space = 0; int other = 0; Scanner scanner = new Scanner(System.in); String str = scanner.nextLine(); //write your code here...... for(int i=0;i='a' && c='A' && c='0' && c

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