nirjari patel wrote:
1) short can fit in double. When I assign "d = s3" , I am getting error "Syntax error on token ";", , expected" on the line immediately before this assignment (int s3 = s2). If I comment "d = s3", this error is gone. Whats wrong with this assignment ? I am getting same error, if I do "s2 = s1" or "f = s2"
This error does not come, if I am creating new declaration. "float f5 = s2" works fine.
So, once a primitive variable is declared, can it be not be assigned value in the same scope ? Does it have to be assigned a value in a method only ? When I assign s2 = s1 in aMethod, it works fine.
Java code, that is not a declaration, can only be in a constructor, initializer, or method.
Henry