[Bluej-discuss] Book: Excercise 1.17

Bryan J. Higgs bhiggs at rivier.edu
Sun Aug 6 02:51:56 BST 2006


Matthew --

The line:

private List<Student> students;

says that you are declaring a field in your LabClass called 'students', 
which is of type 'List of Students'.
A List is one type of 'container' class, which can contain zero or more 
objects.
A List of Students may only contain objects of type Student (which must 
be the name of a class). 
If you don't have a class called Student in your program, then your 
program won't compile, because the compiler won't know what 'Student' means.

You could write a simple student class something like:

public class Student
{
    private String name;

    public Student(String nm)
    {
        name = nm;
    }

    public String getName()
    {
        return name;
    }
}

I hope that helps

Bryan

Matthew Brandt wrote:
> Bruce, thank you for the input, I just updated to the most recent Java 
> Version, I was running 1.4.x. Unfortunately that wasn't the fix. As 
> for what Josh recommended, I'm afraid to say that I'm a bit confused. 
> What is the last line of code that I need to add?
>
> import java.util.List;
> import java.util.ArrayList;
>
> and, a Student class. - What do you mean by this?
>
> matt
>
> ------------------- previous message-----------------------
> From Excercise 1.17 (lab-classes), 
> http://bluej.org/download/download.html 
> <http://bluej.org/download/download.html>
>
> >>public class LabClass
> >>{
>     >>private String instructor;
>     >>private String room;
>     >>private String timeAndDay;
>     >> private List<Student> students;
>     >>private int capacity;
> ------------------------------------------------------------------------
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20060806/47c139f0/attachment.html


More information about the bluej-discuss mailing list