Help on Getters and Setters in Java
Posted: Tue Apr 26, 2011 9:10 am
Hello Friends I am Back After a While
I am leaning Java From Head first java Book and with helps of a friend of mine Who is in UCSC.
First I didn't have any knowledge in OOP and Now i am Getting Better with it.
I found a Thing called Getters and Setters in java. I think they are Related to Encapsulation in Java which use to Hide data from the users to prevent unnecessary changes. Like Hiding Variables not to change them into unacceptable values,
Am I right( I mean Encapsulation Thing Have i got it Right? ) ?
But I am not clear with Getters and Setters in java.
But I saw there are two Methods one is a Setter the other is a Getter. And One Method returns a Value and The other one take Arguments via Method's Parameters.
I Used Google but those Examples didn't Suit me Well. I think you Guys will fill me Up Very well about this.
Please Someone Explain them with Examples.
And another thing Can some one give me a Link or a ebook that have Java exercises with Answers? I Googled for that too but no good ones either.
Thanks

I am leaning Java From Head first java Book and with helps of a friend of mine Who is in UCSC.
First I didn't have any knowledge in OOP and Now i am Getting Better with it.
I found a Thing called Getters and Setters in java. I think they are Related to Encapsulation in Java which use to Hide data from the users to prevent unnecessary changes. Like Hiding Variables not to change them into unacceptable values,
Am I right( I mean Encapsulation Thing Have i got it Right? ) ?
But I am not clear with Getters and Setters in java.
But I saw there are two Methods one is a Setter the other is a Getter. And One Method returns a Value and The other one take Arguments via Method's Parameters.
I Used Google but those Examples didn't Suit me Well. I think you Guys will fill me Up Very well about this.
Please Someone Explain them with Examples.
And another thing Can some one give me a Link or a ebook that have Java exercises with Answers? I Googled for that too but no good ones either.
Thanks