Creating member functions
Let's go back to our Person class, that is, the Person.java file, and provide people with some more functionality. So, the beauty of object-oriented Java is that we're already beginning to think about instances of our Person class as physical objects. This makes anticipating the questions that will be asked of them much easier.
For example, when I meet someone new, I'd either want to know their first name or their full name in most cases. So wouldn't it be nice if our person stores a string called fullName that people could just ask of rather than having to individually acquire their first and last names?
Now, of course, simply adding another member variable like this is unwieldy because the people creating a new ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access