Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a public interface?

Tags:

java

"Using only the public interface of the linked list class, write a method public static void reverse(LinkedList staff) that reverses the entries in a linked list."

The part of all of that I'm not understanding is the first part. What does it mean by public interface of linked list class? Do I create a new class file that starts with something like public interface linkedlist? Can I add the method as a inner class within my main class?

like image 442
Seaker33 Avatar asked Dec 28 '22 20:12

Seaker33


1 Answers

The question is unnecessarily vague. What it's trying to ask is "using only the methods and fields of LinkedList that have the access modifier public, write this method."

You can put the method you write in any class you like, but the restriction says that you may only use public methods and fields on LinkedList to write it.

This also means that you can't create a subclass of LinkedList and use its protected methods.

like image 176
dlev Avatar answered Jan 16 '23 04:01

dlev