Output and Printing Comments


  • public class Main {
    public static void doStuff(String name){
    name = name + "!";
    String hello = "Hello ";
    String message = hello + name;

    How come each input doesn't print out on their own line?

  • @Ian, Sorry, the correct code is with a lowercase 'L', not an uppercase I: System.out.println. It stands for Print Line.

  • Thanks, this same issue had me stumbled for both of the Array Loop Practices too.

  • You can complete the task with only one line: System.out.printIn([Some Stuff]);

  • I agree with Cliff, that is how I did it:
    string + variable + char

  • nice article

  • I like it

  • It's just as simple as forgetting the exclamation point to be incorrect.

  • System.out.println("Hello " + name + "!");

  • @Sagar, please don't post the answers here. Instead you can link to your submission from the Submissions page.

  • I got all the results correct, and it says "Incorrect". Why ?

  • public static void doStuff(String name){
    name = "Jim!";
    String hi1 = "Hello ";
    String hey1 = hi1 + name;
    name = "Sarah!";

  • I don't quite understand this, can someone help me by explaining why
    when I do
    name = "Jim";
    System.out.println("Hello " + name + '!');

    it prints four
    Hello Jim
    Hello Jim
    Hello Jim
    Hello Jim

    I don't understand.

  • @AdhurimEsati, you are given the the String name each time as a parameter, you just need to print that.

  • another simple solution :
    System.out.println ("Hello "+name+"!");

  • import java.util.Scanner;
    public class Main {
    public static void main (String[] args){

        Scanner input= new Scanner (System.in);
        System.out.print ("Enter any Name: ");
        String name=input.nextLine();
        System.out.println ("Hello " + name + "!");


  • import java.util.Scanner;
    public class Main(){

    public static void main(String[] args){
    String name="Nisha";
    System.out.print("Hello" + name);

Contact Us
Sign in or email us at [email protected]