Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects Meet Objects Methods

John Hay
John Hay
Courses Plus Student 3,478 Points

getCharacterName returns the Character Name of the string object BUT...

if the string is character name how does the getter work if Java is case sensitive?

The string characterName is not the same as CharacterName?

When using the getter we capitalise the C of character which is lowercase in the string?

3 Answers

That is how you define function name only

you start with lowercase and all other words starts with uppercase first letter


// function

// variable

so getMyName() is more readable than getmyName(), isnt it?

John Hay
John Hay
Courses Plus Student 3,478 Points

So getMyName is a function which you have chosen to call getMyName. Its not using the variable myName in anyway unless we choose to use that variable as part of the function. Is that correct?

getMyName in this example should return myName variable, so in the getter you can modify return if need, that's why we don't use directly variable from class