All Questions

1645
votes
39answers
557001 views

"implements Runnable" vs. "extends Thread"

From what time I've spent with threads in Java, I've found these two ways to write threads: With implements Runnable: public class MyRunnable implements Runnable { public void run() { //...
506
votes
14answers
735796 views

Implements vs extends: When to use? What's the difference?

Please explain in an easy to understand language or a link to some article.
23
votes
2answers
59599 views

What's the difference between the implements & extends keywords in Java

What's the difference between the following keywords in Java: implements, extends?
28
votes
2answers
36477 views

Why "extends" precedes "implements" in class declaration

Why implements must always be written after extends in class declaration for example: public class Register extends ActionSupport implements ModelDriven Why not public class Register implements M...
7
votes
6answers
6065 views

java.lang.Number doesn't implement "+" or any other operators?

I'm creating a class which is supposed to be able to be used with an array of any type of number (float, int, etc), so here is one method I have: // T extends Number public synchronized T[] average()...
34
votes
3answers
75390 views

Interface extends another interface but implements its methods

In java when an interface extends another interface: Why does it implement its methods? How can it implement its methods when an interface can't contain a method body How can it implement the method...
9
votes
3answers
3582 views

implements vs extends in generics in Java

Can someone tell me what the differences between the first and second codes are? MaxPQ stands for priority queue, which is a collection of "Key" objects that can be compared with each other. Code 1:...
25
votes
3answers
7499 views

Extending vs. implementing a pure abstract class in TypeScript

Suppose I have a pure abstract class (that is, an abstract class without any implementation): abstract class A { abstract m(): void; } Like in C# and Java, I can extend the abstract class: cla...
15
votes
3answers
18614 views

Check if a generic T implements an interface

so I have this class in Java: public class Foo<T>{ } and inside this class I want to know if T implements certain interface. The following code DOES NOT work but it's the idea of what I want...
5
votes
2answers
951 views

Cyclic inheritance and interfaces - class A can't implement class B interface while class B implements A interface

I have: public class A implements BListener { public interface AListener {} } public class B implements AListener { public interface BListener {} } So, if I understand correctly the cyclic...

Previous Next