From 652d227982a0b1b8298038a4ee9d3ac1cc62516e Mon Sep 17 00:00:00 2001 From: Prasoon Date: Wed, 24 Jan 2018 21:27:30 +0530 Subject: [PATCH 1/2] Close the scanner --- Others/CountChar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Others/CountChar.java b/Others/CountChar.java index 1c8dcfea..25f23d61 100644 --- a/Others/CountChar.java +++ b/Others/CountChar.java @@ -14,7 +14,7 @@ public class CountChar { 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."); } From 206b9aa75f38ea9767d25e57239b43f4fe4de8e7 Mon Sep 17 00:00:00 2001 From: Prasoon Date: Wed, 24 Jan 2018 21:28:38 +0530 Subject: [PATCH 2/2] Change access specifier to private --- Others/CountChar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Others/CountChar.java b/Others/CountChar.java index 25f23d61..6504aabb 100644 --- a/Others/CountChar.java +++ b/Others/CountChar.java @@ -24,7 +24,7 @@ public class CountChar { * @return int: Number of characters in the passed string * */ - public static int CountCharacters(String str) { + private static int CountCharacters(String str) { int count = 0;