命令行无法打印某些打印语句

时间:2016-06-05 13:20:59

标签: java

所以我有一个程序,它在一行中打印出一个存储在对象中的变量。它在我尝试过的任何IDE(blue-J和Eclipse)中运行得非常好,但是当我在cmd中运行它时它只是空白,任何想法出了什么问题?

代码图片及其在IDE与CMD上的运行方式 Image of code and how it runs on IDE vs. CMD

2 个答案:

答案 0 :(得分:0)

ohh i think command line has small limits on words to display the and i think the first print was covered by the second print you should use println or do something like this :

System.out.println(ans + " with score " + smallestAccept[i].getScore());

答案 1 :(得分:0)

试试这个:

System.out.println(ans);
System.out.print(" with score: " + smallestAccept[i].getScore() + "\n");

或者这个:

@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, 
        property="name", scope=Player.class)
public class Player
{
    public String name;

    public Player() {}
    public Player(String name) { this.name = name; }

    public String toString() {
        // prints name and java object id 
        return name + "-" + super.toString();
    }
}
相关问题