课程: Java Object-Oriented Programming

今天就学习课程吧!

今天就开通帐号,24,600 门业界名师课程任您挑!

Exploring encapsulation in Java string class

Exploring encapsulation in Java string class - Java教程

课程: Java Object-Oriented Programming

Exploring encapsulation in Java string class

- With the good foundation of encapsulation, we can begin to explore how the Java programming language, uses encapsulation in some of its built-in classes. Exploring more examples will help you better understand this object oriented principle, and recognize the scenarios it should be used in. One common Java class that uses encapsulation, is the string class. To find out more about the string class, we'll click into it using our IDE. I'm on a Mac, so I'll do Command Click, but it may be different on your machine. This class is pretty large at over 3000 lines, but we'll break it into parts and work through it, to see how it uses encapsulation. A string is made up of characters, and those character values actually live in the form of bytes and a byte array. This is all hidden away from us and the way we use strings in everyday programs. This means, even if things inside the string class change, it won't affect the rest…

内容