Advertisement
Vladkoheca

sedmaNew.java

Mar 12th, 2025
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.  
  7.         String sentence = sc.nextLine();
  8.         char[] arr = new char[sentence.length()];
  9.         int chCount = 0;
  10.  
  11.         for (int i = 0; i < sentence.length(); i++) {
  12.             arr[i] = sentence.charAt(i);
  13.             if (arr[i] == ' ') {
  14.                 continue;
  15.             }
  16.             chCount++;
  17.         }
  18.         System.out.println(chCount);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement