Results 1 to 5 of 5
  1. #1
    thokchom is offline Member
    Join Date
    Aug 2016
    Posts
    9
    Rep Power
    0

    Question Multiple variable with single println

    Hi, I am new in this .............. please need help....... when I try to print multiple variable in a single println, not able to give space or coma or something separate for different value

    package lession_1;

    import java.util.Scanner;

    public class Nested_if_else {

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner scan6 = new Scanner(System.in);

    System.out.println("enter first number:");
    int a = scan6.nextInt();
    System.out.println("enter second number:");
    int b = scan6.nextInt();
    System.out.println("enter third number:");
    int c = scan6.nextInt();


    System.out.println("entered number are:" +a + b + c);

    scan6.close();

    }

    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Multiple variable with single println

    when I try to print multiple variable in a single println, not able to give space or coma or something separate for different value
    Please post the program's current output, add some comments saying what is wrong with it and show what you want the output to look like.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    theunlockeRRR is offline Code Child
    Join Date
    Aug 2016
    Location
    Serbia
    Posts
    45
    Rep Power
    0

    Default Re: Multiple variable with single println

    Not sure what was your question, but I'm guessing you are trying to insert space between a b c? If that is your question then you can do it by simply doing this:
    Java Code:
    System.out.println("entered number are: " +a + " " + b + " " + c);

  4. #4
    thokchom is offline Member
    Join Date
    Aug 2016
    Posts
    9
    Rep Power
    0

    Default Re: Multiple variable with single println

    ohhh yes..... why the simple logic I could not understand....... thanks a lot.

  5. #5
    thokchom is offline Member
    Join Date
    Aug 2016
    Posts
    9
    Rep Power
    0

    Default Re: Multiple variable with single println

    Sure......... thanks for reply.

Similar Threads

  1. Split multiple records for a single xml
    By biplab.nits in forum XML
    Replies: 2
    Last Post: 06-23-2013, 04:05 PM
  2. Take multiple inputs in a single line.
    By kunalgaurav18 in forum New To Java
    Replies: 13
    Last Post: 10-27-2012, 05:36 AM
  3. Is it possible to capture println data inside variable?
    By africanhacker in forum New To Java
    Replies: 3
    Last Post: 12-03-2011, 02:36 PM
  4. Multiple Java in a single BOX
    By luke_devon in forum New To Java
    Replies: 2
    Last Post: 07-05-2010, 01:59 PM
  5. variable to accept a single object
    By Rgfirefly24 in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 04:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •