From 2638ce639608aa84bb087ea42c37905c63fed548 Mon Sep 17 00:00:00 2001 From: Prasoon Date: Wed, 31 Jan 2018 15:59:28 +0530 Subject: [PATCH 1/2] Set method to private --- Others/countwords.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Others/countwords.java b/Others/countwords.java index 30806e13fbc9..a72ef9c9cb0a 100644 --- a/Others/countwords.java +++ b/Others/countwords.java @@ -18,7 +18,7 @@ public static void main(String[] args){ input.close(); } - public static int wordCount(String s){ + private static int wordCount(String s){ if(s.isEmpty() || s == null) return -1; return s.trim().split("[\\s]+").length; } From f1200c06cedf3f5cb581ee5fb87af3a17b068a98 Mon Sep 17 00:00:00 2001 From: Prasoon Date: Wed, 31 Jan 2018 16:00:04 +0530 Subject: [PATCH 2/2] Fix a logical error --- Others/countwords.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Others/countwords.java b/Others/countwords.java index a72ef9c9cb0a..a93aa1a33833 100644 --- a/Others/countwords.java +++ b/Others/countwords.java @@ -19,7 +19,7 @@ public static void main(String[] args){ } private static int wordCount(String s){ - if(s.isEmpty() || s == null) return -1; + if(s.isEmpty() || s == null) return 0; return s.trim().split("[\\s]+").length; }