Jay Orsaw wrote:So I'm a bit confused on the whole point on Interfaces the creation of a new class is supposed to be *Class* *name* = new *Interface();* right?
From an example in class it seemed like all the interface did was list the method calls and such and in the normal class
instead of "public void *name*" you could just do *name*?
So what purpose does this serve, is there special instances we should use Interfaces?
Jeff Verdegan wrote:
Stephan van Hulst wrote:
Jeff Verdegan wrote:
Tsk tsk ;)
Jay Orsaw wrote:Basically the interface is like a set of things to do "add() remove()" etc that depending on the class could do different things, but all use the same interface? The add for one class could be different from the add for another class, but if they implement the same interface it will have the same parameters and such that it works with?
Jay Orsaw wrote:Thanks I was just able to find the code we did...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Jay Orsaw wrote:Thanks I was just able to find the code we did...
I shortened a few very long lines in your code (67, 81 and 260(split in two)) because it screws up the windowing here.
BTW, that's an awful lot of code to go through; in future, you might want to just post the relevant parts. Also, the indentation isn't too great.
Winston
Jay Orsaw wrote:EDIT: i cannot even remove it, for some reason I cannot edit my own work? Is there a time limit, or since you edited it did it mess up my editing capabilities?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
The point of interfaces is that you may want to declare useful behavior, but don't have the means to implement that behavior yet, or that the specific implementation doesn't matter.
SCJP
Visit my download page
Jay Orsaw wrote:So after reading this https://coderanch.com/t/387137/java/java/Extends-vs-Implement to get a better understanding I think I've got it. Interfaces seem to just be a skeleton for your classes to use, in which all of the methods of an interface must be used.
When you extend a class you can use some methods from the super class, or override methods of the super class to do what you want.
Also I have a class called "Face" and I was trying out to Extends the Rectangle Class. I was able in my "Draw" Class to say so you can also throw a superclass in front?
me wrote:The left side says, "I need this 'list' variable to be of type List." Whether we use an interface, abstract class, concrete class that's a leaf of the hierarchy, or concrete class that has subclasses on the LHS, we're saying "I need something that IS-A 'this type', but it can also be any subtype."
The only issue I see is that it only uses the methods in the Rectangle2D class which is an issue and it seems like no point to really do it this way
One last thing, what exactly would the difference be in saying compared to if DList has the same methods what is different?
Jay Orsaw wrote:EDIT: i cannot even remove it, for some reason I cannot edit my own work? Is there a time limit, or since you edited it did it mess up my editing capabilities?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
The short answer is yes.Jay Orsaw wrote:. . . by using an interface that I can sort classes that implement that interface? . . .
Campbell Ritchie wrote:
The short answer is yes.Jay Orsaw wrote:. . . by using an interface that I can sort classes that implement that interface? . . .
The long answer is y-e-e-e-e-e-s-s-s-s, or if you prefer to avoid my silly jokes, look at this section in the Java Tutorials, which I think will answer your question.
Campbell Ritchie wrote:
The short answer is yes.Jay Orsaw wrote:. . . by using an interface that I can sort classes that implement that interface? . . .
The long answer is y-e-e-e-e-e-s-s-s-s, or if you prefer to avoid my silly jokes, look at this section in the Java Tutorials, which I think will answer your question.
Campbell Ritchie wrote:That is difficult to read, but I think it looks correct.
Campbell Ritchie wrote:Don’t know.
I wish to win the lottery. I wish for a lovely piece of pie. And I wish for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|