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 Data Structures - Retired Organizing Data Interfaces

Mher Allahverdi
Mher Allahverdi
1,686 Points

What went wrong here?

https://w.trhou.se/f5czmodi22

Javac Example.java didn't have any issues with the code but something went wrong as soon as you run it:

This is a new Treet: Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%s' at java.util.Formatter.format(Formatter.java:2519)
at java.util.Formatter.format(Formatter.java:2455)
at java.lang.String.format(String.java:2940) at com.teamtreehouse.Treet.toString(Treet.java:18)
at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2886)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2763)
at java.util.Formatter.format(Formatter.java:2520)
at java.io.PrintStream.format(PrintStream.java:970)
at java.io.PrintStream.printf(PrintStream.java:871)
at Example.main(Example.java:24)

Also can someone show me how to link my code properly like other people's questions :]? I mean the snapshot works too but it seems like everyone posts their questions the other way.

2 Answers

In Treet.java you have a + instead of a comma before mDescription here:

@Override
  public String toString () {
   return String.format ("Treet: \"%s\" by %s on %s", 
     mDescription, mAuthor, mCreationDate); 
  }
Mher Allahverdi
Mher Allahverdi
1,686 Points

Awesome! Thank you very much Kris :D

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,859 Points

Hi Mher Allahverdi

[edited]

To format code for the Community, you'll need to use Markdown. There is a Cheatsheet link above the Post button, or you can take the quick Markdown Basics Course here on Treehouse.

Hope you get it solved soon.

:) :dizzy: