Hi,
can anybody explain me what is the difference between these two constructions?
String s;
while (!(s = reader.readLine()).equals("exit")) {
try {
if (s.contains(".")) {
vs
String s;
while (!(reader.readLine()).equals("exit")) {
s = reader.readLine();
try {
if (s.contains(".")) {
print(Double.parseDouble(s));
The first case works as expected (after entering "exit" the program stops working). The second one behaves in a different way (doesn't stop the program after entering "exit").
Why both of these constructions don't work at the same way? In both cases we check if a user input equals "exit". After that variable s is set to reader.readLine().