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 trialNoelle Acheson
610 Pointswrong number of arguments
Hello,
I get a java.lang.IllegalArgumentException - wrong number of arguments error, not sure why?
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;
}
}
3 Answers
Craig Dennis
Treehouse TeachergetRemainingChars
shouldn't take a parameter. mText
is accessible, without passing it in.
Hope that helps!
Kristian Terziev
28,449 PointsYou 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
610 PointsThanks! Removing the getRemainingChars parameter works!
karis hutcheson
7,036 Pointskaris hutcheson
7,036 PointsIt 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.