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

Noelle Acheson
Noelle Acheson
610 Points

wrong number of arguments

Hello,

I get a java.lang.IllegalArgumentException - wrong number of arguments error, not sure why?

Tweet.java
public class Tweet {
  public static final int MAX_CHARS = 140;

  private String mText;

  public Tweet(String text) {
    mText = text;
  }

  public String getText() {
    return mText;
  }

  public int getRemainingChars(String mText) {
    int remainingChars = MAX_CHARS - mText.length();
    return remainingChars;
  }
}

It would help a lot if you put the exact error in your question. Also, are we sure the error isn't originating in your Example.java file? I don't see any place where you're calling a method here.

3 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

getRemainingChars shouldn't take a parameter. mText is accessible, without passing it in.

Hope that helps!

You called a method and passed in the wrong number of arguments. Check your methods. If you can't find the error post all your code (all files) + the error itself with the line number and everything. Thanks

Noelle Acheson
Noelle Acheson
610 Points

Thanks! Removing the getRemainingChars parameter works!