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:
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:
Copyright © 2021 Jogjafile Inc.


You're re-declaring
x, so in the lineThe
xon the right is not the samexyou previously declared. So its value defaults to 0 so(int)xis 0. You normally wouldn't be able to have twoxvariables. That's a thingjshelllets you do, but in normal Java you couldn't do.See this: