Merge pull request #370 from GammaBurst101/change

Closed scanner and changed a method to private
This commit is contained in:
Varun Upadhyay 2018-01-24 09:20:44 -08:00 committed by GitHub
commit 81d3e9bf4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,7 @@ public class CountChar {
Scanner input = new Scanner(System.in); Scanner input = new Scanner(System.in);
System.out.print("Enter your text: "); System.out.print("Enter your text: ");
String str = input.nextLine(); String str = input.nextLine();
input.close();
System.out.println("There are " + CountCharacters(str) + " characters."); System.out.println("There are " + CountCharacters(str) + " characters.");
} }
@ -24,7 +24,7 @@ public class CountChar {
* @return int: Number of characters in the passed string * @return int: Number of characters in the passed string
* */ * */
public static int CountCharacters(String str) { private static int CountCharacters(String str) {
int count = 0; int count = 0;