...
Add code to test the accept
method of EmptyIntList
. What can we do here?
Also, remove the public
access from the EmptyIntList
class. By default, a class is "package-private", i.e., it is known within the package, but not from outside. If you try to compile TestEmptyIntList.java
now, you will get an error message. Try it to see what happens.
You need to add the statement import funList.*
; to the top of TestEmptyIntList.java
to indicate to the compiler that you are using all the public classes in that package. Try to compile it again. Is everything OK?
Now, remove the public
access from the EmptyIntList
class. By default, a class is "package-private", i.e., it is known within the package, but not from outside. Try to compile again. You should see a few error messages saying that you can't use EmptyIntList.java
because it is not public. This is because the TestEmptyIntList
class is not part of the funList
package. One way to resolve this problem by making TestEmptyIntList
part of the funList
package. A class of a package can access all the classes (public or "package-private") in the package. However this is not a good solution in general because a client may be using many classes from different packages, but no class can be part of more than one package. For now, just make EmptyIntList.java
public again, and recompile TestEmptyIntList.java
. You should get no error. Try to run Test_List.java
now by click the Test button in DrJava.
...