0

Hello guys im having problem with importing java.io.*; When i do this i cannot resolved PrintStream. I tried to import only PrintStream and the problem was the same. I readed articles here and at other places about changing my libraries, cleaning project, refreshing it but the problem is still there? Can someone help me?

import java.io.*;
import java.util.ArrayList;

public class Group {

    private String name;
    private ArrayList<Student> students;

    public Group(String name){
        this.name = name;
        this.students = ArrayList<Student>();
        }

    public String getName() {
        return this.name;

    }

    public ArrayList<Student> getStudents() {

        return this.students;

    }

    public void addStudent(Student student) {
        students.add(student);

    }

    public void printStudents(PrintStream output) {
        output.printf("Group name: %s%n", this.name);
        output.printf("Students in group:%n");
        for (Student student : this.students) {
            output.printf("  Name: %s%n", student.getName());

        }

    }

}

And in the end i still cannot resolve PrintStream to a type

4

1 回答 1

0
import java.io.PrintStream;

应该管用。

或者,如果您在同一个包中有另一个名为 PrintStream 的类:

public void printStudents( java.io.PrintStream output ) {
   ...
}

Eclipse 中的 Ctrl-Shift-O。

Javadoc:java.io.PrintStream

于 2013-03-31T16:40:16.277 回答