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 (Retired) Creating the MVP Remaining Characters

Daniel Marsh
Daniel Marsh
4,533 Points

im getting Whoops: java.lang.illegalarguement wrong number of arguments

I'm unsure whats going on I'm getting the illegal arguments but not following what it wants beyond that Thank you in advanced

Tweet.java
public class Tweet {
  private String mText;
  public static final int CHARACTER_LIMIT = 140;

  public Tweet(String text) {
    mText = text;
  }
  public int charAvailable(int remainingChar){
    remainingChar = CHARACTER_LIMIT - mText.length();
    while (remainingChar < CHARACTER_LIMIT){
      System.out.print(remainingChar);
    }

  }


  public String getText() {
    return mText;
  }

}

2 Answers

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Daniel,

you think too complicated :)

Create a method that returns the difference of your constant CHARACTER_LIMIT and the number of characters inside mText.

Your code can look like this:

 public int charAvailable(){ 
// no parameter needed

    int remainingChar = CHARACTER_LIMIT - mText.length(); 
// create an integer to store the number of remaining characters

return remainingChar;
// return the remaining number
    }

Let me know if you need more help

Grigorij

Daniel Marsh
Daniel Marsh
4,533 Points

ty Grigorij you are awesome I cant believe I over thought that so much lol.... for some reason I thought it wanted me to stop it at the MAX_LIMIT amount thank you

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Daniel,

I am sure that overthinking is a big part of the Java game :)

DonΒ΄t stop overthinking ...

Grigorij