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 Basics Using your New Tools Coding the Prototype

Michael Lopez
Michael Lopez
1,483 Points

Console Output just reads "at java..."

I get the prompts for entering in a name, an adjective, etc. However, when the prompting for words is finished, I get this output in the console below.

    at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2720)                                               
    at java.util.Formatter.parse(Formatter.java:2560)                                                                
    at java.util.Formatter.format(Formatter.java:2501)                                                               
    at java.util.Formatter.format(Formatter.java:2455)                                                               
    at java.io.Console.format(Console.java:170)                                                                      
    at java.io.Console.printf(Console.java:209)                                                                      
    at TreeStory.main(TreeStory.java:21)

Can anyone please point out problems with my code? Thanks in advance!

import java.io.Console;

public class TreeStory {

public static void main(String[] args) {
    Console console = System.console();
    /*  Some terms:
        noun - Person, place or thing
        verb - An action
        adjective - A description used to modify or describe a noun
        Enter your amazing code here!
    */
  // __Name__ is a __adjective__ __noun__. They are always __adverb__ __verb__.//
  String name = console.readLine("Enter a name:  ");
  String adjective = console.readLine("Enter an adjective:  ");
  String noun = console.readLine("Enter a noun:  ");
  String adverb = console.readLine("Enter an adverb:  ");
  String verb = console.readLine("Enter a verb ending with -ing:  ");

  console.printf("Your Treestory:\n--------------\n");
  console.printf("% is a %s %s.  ", name, adjective, noun);
  console.printf("They are always %s %s. \n", adverb, verb);
}   

}

5 Answers

This line is missing an 's': console.printf("% is a %s %s. ", name, adjective, noun);

musab abdi
musab abdi
2,096 Points

console.printf("Your Treestory:\n--------------\n"); so what is the point of this

That would print the title- "Your Treestory" with a dashed line underneath it. It sounds like there will be more information to follow.

It looks like it is set up as a title.

musab abdi
musab abdi
2,096 Points

like what ? and sorry i am new in tree house

After looking at the code above it will print these two lines underneath what you are asking about:

console.printf("%s is a %s %s.  ", name, adjective, noun);
  console.printf("They are always %s %s. \n", adverb, verb);

If you are wanting to understand how it is written:

The "%s" is a place holder for a variable after the comma that follows the ending quotes. The "\n" is a new line character; any time that you see that in code that means that whatever follows that will be on the next line in the output.

The variables at the ends of the lines of code that I mentioned are created earlier in the code; something is eventually put into the variable and then it is being inserted into their printf output.

The programmer can make any kind of variable they want as long as they follow the syntax rules. They can make a variable equal to some calculation or make it equal to user input and then later print it out as part of the program.

I hope this makes sense to you. Let me know if you are still struggling with the concepts here.