在java中在同一行打印 [英] printing in the same line in java

查看:43
本文介绍了在java中在同一行打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 Items 的基类和 3 个派生类,在 Items 基类中我有一个表单的打印功能

I have a base class called Items and 3 derived classes, and within the Items base class i have a print function of the form

public void print(){
        System.out.println("ID " + id + " Title " + title + " <" + year + "> ");
    }

并且在每个派生类中,我通过 super.print(); 调用 Items 打印函数,然后是与派生类相关的特定打印函数.

and within every derived class I call the Items print function through super.print(); which is followed by a specific print function relating to the derived class.

我的问题是,每当从派生类之一执行打印时,打印的文本不在同一行上.所以 super.print() 将在派生类打印函数上方的行中.我如何让它们在同一条线上?

My problem is, whenever the printing is executed from one of the derived classes the printed text is not on the same line. So super.print() will be in the line above the derived class print function. How do I get them both to be on the same line?

推荐答案

不要在基类上做 println 使用 print 代替

Do not do println on the base class use print instead

这篇关于在java中在同一行打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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