Playing Compiler
Determine the problem(s) with each version of the following readCharacterData() methods?
Version I
public void readCharacterData() { int c; int count = 0; InputStreamReader link = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(link); while ( (c = br.read()) != -1) { Count+ +; System.out.println(c + " " + (char)c); } System.out.println("Number of Characters: " + count); }Version II
public void readCharacterData() throws IOException { int c; int count = 0; BufferedReader br = new BufferedReader(System.in); while ( (c = br.read()) ! = -1) { Count+ +; System.out.println(c + " " + (char)c); } System.out.println("Number of Characters: " + count); }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.