diff --git a/Others/countwords.java b/Others/countwords.java index 30806e13fbc9..a93aa1a33833 100644 --- a/Others/countwords.java +++ b/Others/countwords.java @@ -18,8 +18,8 @@ public static void main(String[] args){ input.close(); } - public static int wordCount(String s){ - if(s.isEmpty() || s == null) return -1; + private static int wordCount(String s){ + if(s.isEmpty() || s == null) return 0; return s.trim().split("[\\s]+").length; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy