Java (Eclim + Vim) “system.out.print"不工作 [英] Java (Eclim + Vim) "system.out.print" not working

查看:33
本文介绍了Java (Eclim + Vim) “system.out.print"不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Java 编程的新手,今天在使用 eclim 和 vim 时,我发现 System.out.println();功能不工作.

I am new to Java programming, and today while messing with eclim and vim, I discovered that the System.out.println(); function is not working.

class apples{
public static void main(String args[]){
    double tuna = 5.28;
    System.out.print(tuna);
}
}

这没有给我结果.

但是当我这样做时:

class apples{
public static void main(String args[]){
    double tuna = 5.28;
    System.out.println(tuna);
}
}

(唯一的区别是println")我得到 5.28,正确的行为.

(The only difference is the "println") I get 5.28, the correct behavior.

有谁知道为什么会发生这种情况,或者这是应该发生的方式吗?

Anyone know why this would happen, or is this the way it should be happening?

推荐答案

.println() 自动附加换行符,.print() 不会.

.println() automatically appends a newline, .print() does not.

System.out 是一个缓冲流;您需要 .flush() 才能显示 .print() 的结果(显然,在您打印之后 执行此操作)..println() 中的换行符导致输出被刷新,这就是为什么你不需要它.

System.out is a buffered stream; you need to .flush() for the result of .print() to appear (do it after you print, obviously). The newline in .println() causes the output to be flushed, which is why you don't need it there.

这篇关于Java (Eclim + Vim) “system.out.print"不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆