Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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