Hello What the main difference between private and protected? What is the meaning of private protected int seconds = 23;? If I have private integer seconds = 23; in private class Hello, Can I change the value of integer seconds when I am in the private class Hello? Thanks
Originally posted by Mike Shn: Hello What the main difference between private and protected? What is the meaning of private protected int seconds = 23;? If I have private integer seconds = 23; in private class Hello, Can I change the value of integer seconds when I am in the private class Hello? Thanks
You should get an error , because using private and protected is not allowed in combination. What i found interesting that JBuilder allowed you to compile but though a warning saying that they took out private and left just protected. Yes you can change the value of youru seconds variable in that class. What you can't do is access that variable outside it. you can define a public geter that will change that value for you. This is called encapsulation.
Originally posted by Mike Curwen: I sense a holy war.
I like to think of it as more of a crusade, really. I may have to work with some of these folks I find it frustrating sometimes to see how much attention is given to the mechanics of the language and yet little given to the principles of Object Orientation. If you look at some of the code in the Java Tutorial, you can't help wonder sometimes if the people who wrote the sample programs knew anything about object orientation or not. It's even more amazing (and frightening) when I show people the initial UML diagrams and code in the first chapter of "Refactoring" and ask them if it is object-oriented and they reply "Yes." It seems that even though Java is supposed to be more OO, it still takes more effort to write OO code than it does to write non-OO code. Junilu