Are visibility keywords in Java actually methods, for example in Ruby?
As the name suggests, in Ruby, "keywords" like private, public, etc. are actually "methods that work on a class, dynamically changing the visibility of methods" ( http://en.wikibooks.org/wiki/ Ruby_Programming / Syntax / Classes ) is this the same in Java?
Thank!
+3
source to share
3 answers
No, it is not. Java is a compiled language, and these keywords are understood by the compiler with specific meanings when it parses your code.
Ruby is not precompiled, so a class definition in Ruby is indeed an executable statement that defines a class at runtime. This is why access modifiers are actually runtime methods in Ruby. Loading classes in Java is completely different.
+1
source to share