Formatted with Google Java Formatter

This commit is contained in:
github-actions
2020-10-24 10:23:28 +00:00
parent a23bac99e8
commit 5d59a2e828
219 changed files with 13758 additions and 14582 deletions

View File

@ -4,21 +4,21 @@ import java.util.Scanner;
public class CountChar {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter your text: ");
String str = input.nextLine();
input.close();
System.out.println("There are " + CountCharacters(str) + " characters.");
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter your text: ");
String str = input.nextLine();
input.close();
System.out.println("There are " + CountCharacters(str) + " characters.");
}
/**
* Count non space character in string
*
* @param str String to count the characters
* @return number of character in the specified string
*/
private static int CountCharacters(String str) {
return str.replaceAll("\\s", "").length();
}
/**
* Count non space character in string
*
* @param str String to count the characters
* @return number of character in the specified string
*/
private static int CountCharacters(String str) {
return str.replaceAll("\\s", "").length();
}
}