Hi, Looking at the code below, I don't understand why the statement at (5) is valid since variable 'height' has not been declared before it is initialized? could somebody help me out? Thanks
Update: Both pieces of code work with 1.4, but neither worked with 1.3.
Note: The UseBeforeDeclaration class above is from the Second Edition of the JLS (section 8.3.2.3). I couldn't find anything to parallel it in the First Edition.
Originally posted by marc weber: Update: Both pieces of code work with 1.4, but neither worked with 1.3.
Note: The UseBeforeDeclaration class above is from the Second Edition of the JLS (section 8.3.2.3). I couldn't find anything to parallel it in the First Edition.
Well, I definitely learned something. Thanks for the example!
What's instructive to me is the way they phrase the comments in the JLS code: "//error - read before declaration." Technically, I suppose it's all the same, but the problem of trying to "read" a variable before it's declared makes more sense to me than discerning "left/right" in something like "int a = b = 20." [ September 21, 2004: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
This is the message i get for the code below C:\Data\bea8.1\jdk141_03\bin\Test2.java:6: cannot resolve symbol symbol : variable j location: class Test2 int i = j = 20; ^ 1 error
Process completed with exit code 1
Does this have anything to do with the version being used ?