farm rubbit hihihihihihi, be aware !!
samantha clarkson wrote:Compiling errors :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The field Vehicle.protectedVehiclefield is not visible
privateVehicleField cannot be resolved or is not a field
The method protectedVehicleMethod() from the type Vehicle is not visible
The method privateVehicleMethod() from the type Vehicle is not visible
farm rubbit hihihihihihi, be aware !!
samantha clarkson wrote:
Well i didnt understand the rules of error messages, why they are different when i use my objects directly in the subclass or in another class TestClass.
When we can say not found and when we can say not visible, and there is any influence if the structure include packages and no direct access? Im confused![]()
is there a documentation about error compilation rules?
samantha clarkson wrote:
And now it becomes more stranger than before, only the private members of the class Vehicle are not found and no errors about the protected ones !!!
Another situation if i use a main methode directly in my Car class :
Henry Wong wrote:
samantha clarkson wrote:
Well i didn't understand the rules of error messages, why they are different when i use my objects directly in the subclass or in another class TestClass.
When we can say not found and when we can say not visible, and there is any influence if the structure include packages and no direct access? I'm confused![]()
is there a documentation about error compilation rules?
A little bit about compilers -- and this is true for all (that I know of) compiled languages. ie. not specific to Java.
When a compiler finds an error, it reports on it, and then if the compiler is in a useable state, continue compiling. As an analogy, let's say you are reading a book, and you encountered something you don't understand, because someone ripped out a page. You report this confusion to the librarian, that there may be content missing, then you check to see if there is a another chapter, and you continue reading.... do you now understand the possible problem?
The compiler continues to the next line, or next block, etc., under the assumption that the error reported wasn't important. It is possible that this assumption is correct. And of course, it is possible that it is not. The error can trigger errors (false positives) where there isn't any because of missing context. The compiler can also miss errors because of the missing context. This is why an experienced programmer always fix the issues in order, going down the list of errors, until the messages don't make sense, then recompile it to get an updated list of errors.... an experienced programmer will also constantly compile to keep this list small.
Anyway, why should you never run a program that didn't compile?? Because the list is *not* in order (actually, there may not be a list). The error message that is printed is the first one encountered when the program is ran -- it may be the first error encountered during compilation, or it may be one of the false positives that was found late in the compilation process.... to repeat, never run code that didn't compile properly.
Henry
farm rubbit hihihihihihi, be aware !!
R. Jain wrote:
samantha clarkson wrote:
And now it becomes more stranger than before, only the private members of the class Vehicle are not found and no errors about the protected ones !!!
Another situation if i use a main method directly in my Car class :
A class cannot see a private member of another class, that is why we say it's private right??
Now as for protected members, they are visible in the derived class through inheritance, but you still can't access it directly..
farm rubbit hihihihihihi, be aware !!
samantha clarkson wrote:
100% with you, the subclass cannot see the private member, but what i didn't know is for the protected one, that it could be accessed just in the Class Car and not in other class using an object type Car.
does scjp exams contain question about expecting error messages?
Thank you
farm rubbit hihihihihihi, be aware !!
get schwifty. tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
|