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 Getting Started with Java Strings and Variables

Fabiyan Adell
Fabiyan Adell
365 Points

Not desired output

Hello, I'm trying print out "Hello, my name is Tiger"Tiger is learning how to write Java"); but it only outputs "Hello, my name is Tiger" Can anyone help what's wrong with my code? Thanks in advance

import java.io.Console;

public class Introductions {

public static void main(String[] args) {
    Console console = System.console();
    // Welcome to the Introductions program!  Your code goes below here
    console.printf("Hello, my name is Tiger");
    console.printf("Tiger is learning how to write Java");

}

1 Answer

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

Hello Tiger Han

Java is an interesting language to learn and I am sure you will love it. By the way, I like your Tiger Avatar!! looks cute.

So I checked your code and found it was working alright. The only thing that you might have missed is saving your work.

You can also use \n on the first line to make the second line drop to a new line for easy readability.

import java.io.Console;

public class Introductions {

public static void main(String[] args) {
    Console console = System.console();
    // Welcome to the Introductions program!  Your code goes below here
    console.printf("Hello, my name is Tiger \n");
    console.printf("Tiger is learning how to write Java");

Hope this helps.

Thanks,