Advertisement
Guest User

Spaces count

a guest
Feb 14th, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public class Program
  2. {
  3.     public static void main(String[] args) {
  4.    
  5.       String text = "Here is the text";
  6.      
  7.       int count = text.split(" ").length - 1;
  8.  
  9.       if(count > 0){  
  10.           System.out.println("عدد المسافات:"+count);
  11.       }else{
  12.           System.out.println("لا توجد مسافات");
  13.       }
  14.      
  15.      
  16.     }
  17.    
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement