e t e t - 3 years ago 166
Java Question

Java interfaces error for list<String> eclipse

what I need to implement

package com.lab3;

public interface Student {

long getStudentNumber();

void setStudentNumber(long s);

String getName();

void setName(String s);

List<String> getSchedule();

void setSchedule(List<String> s);


The last two I get an error "list cannot be resolved into a type"

How to fix?

Answer Source

That's because you need to import the class. In Java, you need to import objects which are defined in a different package if you want to use them. The List interface is defined in java.util, so you need to import it. If you are using an IDE, you can over your mouse over the error and it will recommended fixes, one of those should be "import". If not, you can add the following line above you interface:

import java.util.List;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download