Question

Im trying to learn some Java, I am using Eclim and after following a tutorial I found that this does not work on Eclim + vim:

class variables{
    public static void main(String args[]){
        double number;
        number = 12.34;
        System.out.print(number);
    }
}

But when I do the same on Eclipse, it does work. The only way I can make it work on Eclim is by using

println

instead of

print

Any ideas on why this would happen??

edit:

Tried this:

class variables{
  public static void main(String args[]){
    double number;
    number = 12.34;
    System.out.flush();
    System.out.print(number);
  }
}

and still nothing. Again, it works on Eclipse, but not on Eclim

Was it helpful?

Solution

use .flush() after .print() because system.out is buffered stream... you'll have to flush the output before you use it.

In .println(), the output gets flushed automatically

OTHER TIPS

It is almost certain that it is indeed working, but you are confusing the output with your prompt, as lack of a newline is making the prompt that waits for your next command be in the same line as your printed result.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top