I am learning java and this logic makes me feel confused. Isn’t here i=20(+1)+20(+1)? Why 41 instead of 42? See this code run at Ideone.com. Answer Effectively, the expression i=i++ + i++; is equal to i=i++ + i;. Why? The latter i++ result value is never used and is not propagated. The result of the postfix addition i++ is used
Tag: jshell
What is the difference between “int x = (int) x” and “x = (int) x” in java if I assign “double x = 2.3”?
if I assign “double x = 2.3”, what is the difference between “int x = (int) x” and “x = (int) x” ? I’m new to java and use python before, in python, if I execute “x = 2.3; x = int(x); print(x)”, x is 2. java: python: Answer You’re re-declaring x, so in the line The x on the
How to quit the JShell and go back to the command-line?
When using the JShell, how do I exit it back to the CMD line? I have already tried ctrl + x and just writing quit, but to no joy. Answer You can use the JShell command to exit as: Side note: Interestingly, with the use of command abbreviations for input shortcuts:- (of course /exi) also, resolves into the same command.