Talk:Interface (Java): Difference between revisions

Content deleted Content added
Implementing WP:PIQA (Task 26)
 
(7 intermediate revisions by 7 users not shown)
Line 1:
{{WikiProject Javabanner shell|class=startStart|importance=mid}}
{{WikiProject Java|importance=mid}}
}}
 
== Interfaces and Abstract Classes ==
Line 20 ⟶ 22:
but can any interfaces(e.g Connection) have defined methods(e.g createStatement)?
 
An interface will not have any body(definition) in it's method. It's methods are made to be overrodeoverride. Think of an interface as a contract. Every method in that contact must be used in your class. You must implement all methods from an interface in the class that will use it. In that class you will override the interfaces methods and give them their body .
 
here is a sample interface
Line 40 ⟶ 42:
:Not just C#, but just about in any OOP language; there is no reason this article should document just one language. However, the merge with [[Protocol (object-oriented programming)]] was opposed, go figure. -- [[user:intgr|intgr]]&nbsp;<sup>[[user talk:intgr|#%@!]]</sup> 07:31, 28 August 2007 (UTC)
 
:: The [[Protocol (object-oriented programming)]] article is both more general and more succinct than this one, and it would suffer from having all the details in this article merged into it. On the other hand, the details in this article are probably of interest to Java developers and it would be unfortunate to lose them in a merge. In addition, it would probably be confusing to have what is called an [[Interface (Java)|Interface]] in Java described using the more exact term [[Protocol (object-oriented programming)|Protocol]], and even more confusing to have [[Protocol (object-oriented programming)|Protocols]] described as [[Interface_(computer_science)|Interfaces]] when that term means something [[Interface_(computer_science)|quite different]] in most object-oriented languages. This being said, I don't see why this article doesn't link to the [[Protocol (object-oriented programming)]] one (and vice versa).[[Special:Contributions/173.226.146.65|173.226.146.65]] ([[User talk:173.226.146.65|talk]]) 00:2832, 24 February 2011 (UTC)
 
:The C# interfaces were copied from Java. They can be documented in the appropriate article. [[User:Mike0001|Mike0001]] ([[User talk:Mike0001|talk]]) 12:45, 21 February 2008 (UTC)
Line 58 ⟶ 60:
 
<span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/128.233.135.237|128.233.135.237]] ([[User talk:128.233.135.237|talk]]) 21:26, 23 July 2010 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->
 
== Generics "extends" interface ==
 
Would it be appropriate to include information about how a generic class uses the "extends" keyword when inheriting from a base class AND multiple interfaces? For a refernce of what I am speaking of, view: http://stackoverflow.com/questions/4258447/what-does-the-java-compiler-do-with-multiple-generic-bounds . [[Special:Contributions/64.55.132.4|64.55.132.4]] ([[User talk:64.55.132.4|talk]]) 18:49, 2 July 2012 (UTC)
 
== Extending interfaces ==
 
Am I right that a concrete class cannot add any new public methods if it is only implementing interfaces and does not have an "extends" relationship with a superclass? It seems to compile but will not expose the method to calling classes. -- [[User:Beland|Beland]] ([[User talk:Beland|talk]]) 19:01, 24 July 2013 (UTC)
 
== Concrete Methods for Interfaces(Defender methods) ==
 
Java 8 is redefining interfaces by allowing them to implement concrete methods: http://www.javabeat.net/virtual-extension-methods-in-java-8/
 
I think it should be added to this page in a special java 8 section, here's the official oracle link: http://www.oracle.com/technetwork/articles/java/lambda-1984522.html <span style="font-size: smaller;" class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/117.194.255.24|117.194.255.24]] ([[User talk:117.194.255.24|talk]]) 18:33, 30 January 2014 (UTC)</span><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
 
== Rework into a non Java-specific 'Interface type' article? ==
 
I've had an idea regarding the proposed merge into the [[Protocol (object-oriented programming)]] article, and [https://en.wikipedia.org/wiki/Talk:Protocol_(object-oriented_programming)#c-HotMess-20221114130000-3mi1y-20221107072700 I've already mentioned it on the relevant threads regarding that proposal], but I figured I should mention it on the talk page for this article as well, seeing as that plan involves this article as well.
 
In short, reworking this article to be about Interface types in general, rather than specifically about Java's <code>interface</code>s. Along the same lines as [[Enumerated type]], [[Function type]], [[Abstract type]], etc. After all, Java's interfaces by themselves probably aren't notable enough for an article of their own (as per [[WP:NOPAGE]]), but, reworking this article to be primarily about interface types/language equivalents (with small sections specifically on Java/C#/TypeScript/Golang's <code>interface</code>s, Python's <code>Protocol</code>, Rust's <code>trait</code>s, etc) would probably be more appropriate.
 
I'm going to refrain from making any major changes pending the outcome of the merge/move discussions over on [[Talk:Protocol (object-oriented programming)]], but I figured I should at least mention it here in advance, whilst I'm thinking about it. [[User:HotMess|<big>🔥</big><b style="color:red;">HOT<i style="color:orange;">m̵̟͆e̷̜̓s̵̼̊s̸̜̃</i></b><big>🔥</big>]] ([[User_talk:HotMess|talk]]・[[Special:Contributions/HotMess|edits]]) 13:27, 14 November 2022 (UTC)