Why not run the code after the while loop?

Run under the debugger code:

import java.io.*;

public class Program {

 public static void main(String[] args) throws IOException {
 char[] buf;
 buf = new char[9];
 BufferedInputStream bf = new BufferedInputStream(System.in);

try{
 int i, j, el;
 j = bf.available();
 char c;
 while(((i = bf.read()) != -1) & j > 0) {
 c = (char) i;
 j = bf.available();
 buf[j] = c;
}
 el = Integer.parseInt(String.copyValueOf(buf));
System.out.println(el);
}
finally{
bf.close();
}
}
}

in the console recruit for example: "123", why is never executed the code below?:

el = Integer.parseInt(String.copyValueOf(buf));

the while loop runs without problems, and then nothing happens.

Why not run the block of code below?

el = Integer.parseInt(String.copyValueOf(buf));
 System.out.println(el);
April 7th 20 at 11:58
1 answer
April 7th 20 at 12:00
Solution
And in the loop condition while(((i = bf.read()) != -1) & j > 0)
really need a bitwise AND ( & ) and not logical (&&)?
Thank you. - carmen.Gutmann91 commented on April 7th 20 at 12:03

Find more questions by tags Java