Neither does a = b. But it's still allowed at compile time.Posted by CornedBee
Because at compile-time it doesn't reference anything.
Code:public class MyClass{ public static void main(String[] args){ MyClass a; MySubclass b; a = new MyClass(); b = new MySubclass(); a = b; // allowed b = a; // fails } } class MySubclass extends MyClass{}Under the context of the code you provided of course the compiler would not be able to determine if the assignment is valid. Under the above code there is no ambiguity(not at least the way i look at it)Posted by CornedBee
How would the compiler know whether the marked assignment is valid? If i is 0 then it is, otherwise it isn't.




Reply With Quote