Simple Encapsulation in Java
Last week I was taught about Encapsulation by my teacher.I've been knowing encapsulation when i started to read e-book java which is SCJP for Java 6.That's a good book to understand deeper about java.I suggest you to read the book. Today i'm gonna show you how to make your class to use encapsulation concept.First of all you have to understand why we must use encapsulation.Sometimes you create a class and you don't want some fields to be accessed by other class.There is a way to make your field cannot be accessed.You can use access modifier "private".Look at the code example :