Results 1 to 6 of 6
  1. #1
    javajames is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Question eliminating new lines in java

    a extremely basic question, but how would i stop java adding new lines after my System.out/in? example;
    Java Code:
    System.out.println("input: ");
    //new line eliminator
    int a = scan.nextInt();
    //new line eliminator
    System.out.println(" " + (a>10));
    (excuse the lack of a class, import scanner object, constructing scanner and method) i would like this to have no new lines, how would i do that. (i.e. out put as below):
    Java Code:
    input: 5 false
    or
    Java Code:
    input: 15 true
    thanks in advance!

  2. #2
    cultclassic is offline Member
    Join Date
    Mar 2011
    Posts
    64
    Rep Power
    0

    Default

    System.out.print("input: ");

  3. #3
    javajames is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default

    thank you, will it scanner (nextInt) generate a new line though? or will print generate a new line before

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,874
    Rep Power
    25

    Default

    will it scanner (nextInt) generate a new line
    Some times a short test program will show you what will happen when code is executed.
    Write a short program using the Scanner class and various of its next... methods and see what happens.
    Its possible to enter several tokens before you press Enter and have the Scanner method read them one by one from the one line vs having to press Enter for each item.
    Experiment and see.

  5. #5
    javajames is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default

    sorry, i am currently unable to access my compiler, but if your still persistent then don't bother

  6. #6
    javajames is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

Similar Threads

  1. Replies: 11
    Last Post: 01-14-2012, 07:46 PM
  2. Cannot Add new Lines
    By capjoel in forum New To Java
    Replies: 3
    Last Post: 04-01-2011, 07:33 PM
  3. What do these lines mean?
    By coding in forum New To Java
    Replies: 5
    Last Post: 02-02-2011, 04:01 AM
  4. Eliminating a line
    By wizar in forum New To Java
    Replies: 5
    Last Post: 11-04-2010, 02:01 AM
  5. Help explain the FOR lines please
    By hydride in forum New To Java
    Replies: 2
    Last Post: 01-20-2010, 12:52 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
  •