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

get method

how do i write that i want the remaining text that shows the remaining max of 140 characters.

i tried: public void getCharacter() { System.out.printf("You have %d left %s\n", mText.getRemainingNumber(), mText.getCurrentCharacter() ); }

what am I doing wrong?

http://teamtreehouse.com/library/java-objects/creating-the-mvp/remaining-characters

Jeremiah Shore
Jeremiah Shore
31,168 Points

It might be better to include some more of your code with your question, specifically, the class file for whatever class mText is.

Also, using markdown makes the code a little more readable. Use the "Markdown Cheatsheet" below each input on these pages, adn the video linked in "Tips for asking questions" on the right to get an understanding of how to use it.

1 Answer

I agree with Jeremiah, very hard to help you if you don't include your code. I am going to guess here, try removing the member variable, it may work:

```public void getCharacter() { System.out.printf("You have %d left %s\n", getRemainingNumber(), getCurrentCharacter() ); }

Keep in mind that if you are declaring a getter method, you need to return something. 

if you need to return a string try:

```public String getCharacter() { String s = String.format("You have %d left %s\n", getRemainingNumber(), getCurrentCharacter() ); return s; }```