• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Keyword input  RSS feed

 
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider the following program which is created and executed in java 1.5
import java.util.Scanner;

public class EchoTextLine {

public static void main(String[] args) {
System.out.println("Enter text :");
Scanner myScanner = new Scanner(System.in);
System.out.println(myScanner.nextLine());
}

}

Try running this program and you will see that the text Enter text: is displayed and one the next line next line the cursor is placed for input from the user, what i would like to know if it is possible to maintain the cursor position just next to Enter text : text this is similar to the one i used to do in C, C++ programming languages.

Thanks in Advance.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java isn't C and Java isn't C++; it is a completely different language.

Try System.out.print() instead of System.out.println();
 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Campbell

That did the Trick.

Thanks again
 
Campbell Ritchie
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!