java 如何在一个类中显示出另外两个类的方法

classEnrolment{publicstaticvoidmain(String[]args){System.out.println("/*-------------... class Enrolment{
public static void main(String[] args)
{
System.out.println("/*-------------------------------------");
System.out.println("My name: ");
System.out.println("My student number: ");
System.out.println("My email address: ");
System.out.println("Assignment number: 2");
System.out.println("-------------------------------------*/");

}
}
public class Student {
private final String fullname;
private final String email;
private final String course;
private final int studentNumber;
public Student() throws IOException {
writeStudent();
Scanner inStream = new Scanner(new File("student1.txt"));
fullname = inStream.next();
email = inStream.next();
course = inStream.next();
studentNumber = inStream.nextInt();
inStream.close();
}
private void writeStudent() throws FileNotFoundException {
Formatter outStream = new Formatter(new File("student1.txt"));
outStream.format("%s %s %s %i", "David Black", "davblk@ipw.edu.au", "1853E", 375428);
outStream.close();
}
public void displayStudInfo() {
System.out.print("\nStudent " + fullname + email + course + studentNumber);
}
}
public class Subject {
private final String subjectcode;
private final String session;
private final int year;
public Student() throws IOException {
writeSubject();
Scanner inStream = new Scanner(new File("subject1.txt"));
subjectcode = inStream.next();
session = inStream.next();
year = inStream.nextInt();
inStream.close();
}
private void writeStudent() throws FileNotFoundException {
Formatter outStream = new Formatter(new File("ubject1.txt"));
outStream.format("%s %s %i", "CSIT455", "Autumn", 2017);
outStream.close();
}
public void displaySubjectInfo() {
System.out.print("\nEnrolment " + subjectcode + session + year);
}
}
这是代码 想要在class Enrolment里面展示出其他两个类最后display的内容
展开
 我来答
子弹非弹子575
2017-04-14 · TA获得超过392个赞
知道小有建树答主
回答量:450
采纳率:20%
帮助的人:188万
展开全部
Student student=new Student();]
student.displayStudInfo();
Subject subject=new Subject();
subject.displaySubjectInfo();
追问
加上了 还是打不出来东西
追答
你把main方法代码发给我看一下
luckxu0926ccc1fdc
2017-04-14 · TA获得超过104个赞
知道答主
回答量:124
采纳率:0%
帮助的人:46.3万
展开全部
要么继承,要么写接口实现
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式