If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.
Why in a Java program that asks for user input the blinking cursor is not positioned where it should be.
Look at this code:
publicstaticvoid main(String args)
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
x = in.nextInt();
System.out.print("Enter another number: ");
y = in.nextInt();
int sum = x + y;
System.out.println("Sum is " + sum);
When I run the program the blinking cursor is never where it should be. Seems to me it should be after the word number: cursor should be here.
But I can never get it there.
Is there something I'm doing wrong when I run my program or is this just a Java quirk?
So where does it happen to be? That works perfectly fine in my case, I ran your code in NetBeans and the following was the output,
Enter a number: 55
Enter another number: 45
Sum is 100
BUILD SUCCESSFUL (total time: 14 seconds)
You can see "55" comes right after "number: " and so on for the next line. The question is which compiler are you using, or what IDE is being used? print must never add "\n" to the output, if that is happening, change the compiler.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
I'm using Eclipse Mars. When I run the program it first shows Enter an integer: with no cursor being shown. I then enter a number and then hit Enter and then what happens is it shows Enter an integer: the second time around but the cursor shows up before the Enter an integer:
It's just dumb.
Why doesn't the cursor automatically get placed after the Enter an integer:
Just annoys me. I'm using Eclipse Mars with whatever compiler the JDK ships with.
I am developing a simple chat application in java. It has two parts Server.java and Client.java. When I run these files on a local network they work fine but when I run them on PCs that are on different networks it does not works. Can anyone please guide me how to do it.