interface

Interfaces — What's the point?

倾然丶 夕夏残阳落幕 提交于 2019-12-17 02:22:50
问题 The reason for interfaces truly eludes me. From what I understand, it is kind of a work around for the non-existent multi-inheritance which doesn't exist in C# (or so I was told). All I see is, you predefine some members and functions, which then have to be re-defined in the class again. Thus making the interface redundant. It just feels like syntactic… well, junk to me (Please no offense meant. Junk as in useless stuff). In the example given below taken from a different C# interfaces thread

When should I use an interface in java? [closed]

烂漫一生 提交于 2019-12-17 02:11:39
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . A good example of when exactly to use interfaces specifically in Java would be ideal and any specific rulings that apply. 回答1: Use interfaces to define an application programming contract (blueprint, interface) which "3rd-party" vendors have to fully adhere and implement.

Is there any ready-made calendar control for iPhone apps? [closed]

梦想与她 提交于 2019-12-17 01:34:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am building an applicaiton for the iPhone that will display upcoming and past events. I settled for a list view, but then I realized that a calendar (just like the one displayed in the "month" view in the built-in Calendar application) would be a best match. However, the iPhone Human Interface Guidelines just

The difference between the Runnable and Callable interfaces in Java

我的梦境 提交于 2019-12-17 01:23:10
问题 What is the difference between using the Runnable and Callable interfaces when designing a concurrent thread in Java, why would you choose one over the other? 回答1: See explanation here. The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Runnable, however, does not return a result and cannot throw a checked exception. 回答2: What are the differences in the applications of Runnable and Callable . Is

How do arrays in C# partially implement IList<T>?

流过昼夜 提交于 2019-12-17 00:43:15
问题 So as you may know, arrays in C# implement IList<T> , among other interfaces. Somehow though, they do this without publicly implementing the Count property of IList<T> ! Arrays have only a Length property. Is this a blatant example of C#/.NET breaking its own rules about the interface implementation or am I missing something? 回答1: New answer in the light of Hans's answer Thanks to the answer given by Hans, we can see the implementation is somewhat more complicated than we might think. Both

What is an interface in Java?

有些话、适合烂在心里 提交于 2019-12-16 20:24:58
问题 Just as a counterpoint to this question: what is an interface in Java? 回答1: An interface is a special form of an abstract class which does not implement any methods. In Java, you create an interface like this: interface Interface { void interfaceMethod(); } Since the interface can't implement any methods, it's implied that the entire thing, including all the methods, are both public and abstract (abstract in Java terms means "not implemented by this class"). So the interface above is

Abstract class in Java

不想你离开。 提交于 2019-12-16 20:05:21
问题 What is an "abstract class" in Java? 回答1: An abstract class is a class which cannot be instantiated. An abstract class is used by creating an inheriting subclass that can be instantiated. An abstract class does a few things for the inheriting subclass: Define methods which can be used by the inheriting subclass. Define abstract methods which the inheriting subclass must implement. Provide a common interface which allows the subclass to be interchanged with all other subclasses. Here's an

Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?

こ雲淡風輕ζ 提交于 2019-12-16 20:04:31
问题 Java doesn't allow multiple inheritance, but it allows implementing multiple interfaces. Why? 回答1: Because interfaces specify only what the class is doing, not how it is doing it. The problem with multiple inheritance is that two classes may define different ways of doing the same thing, and the subclass can't choose which one to pick. 回答2: One of my college instructors explained it to me this way: Suppose I have one class, which is a Toaster, and another class, which is NuclearBomb. They

Find Java classes implementing an interface [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-16 20:03:54
问题 This question already has answers here : How can I get a list of all the implementations of an interface programmatically in Java? (11 answers) Closed 6 years ago . Some time ago, I came across a piece of code, that used some piece of standard Java functionality to locate the classes that implemented a given interface. I know the functions were hidden in some non-logical place, but they could be used for other classes as the package name implied. Back then I did not need it, so I forgot about

Find Java classes implementing an interface [duplicate]

▼魔方 西西 提交于 2019-12-16 20:03:38
问题 This question already has answers here : How can I get a list of all the implementations of an interface programmatically in Java? (11 answers) Closed 6 years ago . Some time ago, I came across a piece of code, that used some piece of standard Java functionality to locate the classes that implemented a given interface. I know the functions were hidden in some non-logical place, but they could be used for other classes as the package name implied. Back then I did not need it, so I forgot about