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 Multiple Format Strings

Shafiqul Islam
Shafiqul Islam
574 Points

I am not sure what is happening here...

I have looked at threads and can't figure out what I'm doing wrong...

Multiple.java
String name = console.readLine("What is your name?  ");
String adjective = console.readLine("Enter an adjective:  ");
String pastTenseVerb = console.readLine("Enter a past tense verb: ");
console.printf("%s really %s this coding exercise %s ", name, adjective, pastTenseVerb);

you must run it with terminal or cmd

import java.io.Console;//import Console class
public class JavaApplication31 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Console console = System.console();
        if (console == null) {
            System.out.println("Unable to fetch console");
            return;
        }
        String name = console.readLine("What is your name?  ");
        String adjective = console.readLine("Enter an adjective:  ");
        String pastTenseVerb = console.readLine("Enter a past tense verb: ");
        console.printf("%s really %s this coding exercise %s ", name, adjective, pastTenseVerb);
    }

}
Shafiqul Islam
Shafiqul Islam
574 Points

Thank you for your help, John, but that did not work.

it works

u must compile and run javac appName.java

java appName

1 Answer

andren
andren
28,558 Points

Challenges are very specific about what they want you to do, and doing anything different or more than what is asked for will often lead to failure.

The challenge asks you to create a name and pastTenseVerb variable and to print them out. It does not asks you to create an adjective variable and it does not ask you to print that out.

If you create only the variables asked for and print them out in the way shown like this:

String name = console.readLine("Enter an name:  ");
String pastTenseVerb = console.readLine("Enter a past tense verb: ");
console.printf("%s really %s this coding exercise.", name, pastTenseVerb);

Then your code will pass the challenge.

Shafiqul Islam
Shafiqul Islam
574 Points

This worked thank you!!