Content deleted Content added
→Multiple Inheritance in Java: new section |
Remove merge proposal |
||
(17 intermediate revisions by 13 users not shown) | |||
Line 1:
{{Talk header}}
{{Old AfD multi |date=17 December 2021 |result='''keep''' |page=Comparison of Java and C++}}
{{WikiProject
{{WikiProject
{{WikiProject Java |importance=low}}
{{WikiProject C/C++ |importance=low }}
}}
{{User:MiszaBot/config
|archiveheader = {{Talk archive}}
|algo = old(365d)
|maxarchivesize = 100K
|minthreadsleft = 5
|minthreadstoarchive = 1
|counter = 2
|archive = Talk:Comparison of Java and C++/Archive %(counter)d
}}
== remove bounds checking ==
Line 695 ⟶ 42:
Anyone who understands multiple inheritance and its problem(s) would know quite well that Java does not support multiple inheritance, and the creators of Java were very vocal and open about their reasons for excluding multiple inheritance from the Java language spec.
[[User:Aquishix|Aquishix]] ([[User talk:Aquishix|talk]]) 12:19, 10 February 2014 (UTC)
== Java Generics Inaccuracy ==
I believe there is an error in the generics vs. templates comparison section.
It says (as of 11/18/2015):
{| class="wikitable"
! '''C++ Templates''' !! '''Java Generics'''
|-
| Templates can be [[Template (programming)#Explicit template specialization|specialized]]—a separate implementation could be provided for a particular template parameter.
|| Generics cannot be specialized.
|}
The below program shows an example of specializing a generic method for a specific template parameter. The "myCount" method is specialized for subclasses (inclusive) of Character. Is this not "providing a separate implementation for a particular template parameter"? It seems to precisely match the definition of "Explicit template specialization" given here: [[Template (programming)#Explicit template specialization]]
<syntaxhighlight lang="java">
import java.util.*;
public class Test {
static <T> int myCount (Iterator<T> iterator, T val)
{
int ret = 0;
while (iterator.hasNext()) {
T entry = iterator.next();
if (entry.equals(val)) ++ret;
}
return ret;
}
static <T extends Character> int myCount (Iterator<T> iterator, T val)
{
System.out.println("weirdcount");
int ret = 0;
while (iterator.hasNext()) {
T entry = iterator.next();
if (entry.equals(val)) ++ret;
}
return ret*3;
}
public static void main (String[] args) {
List<Integer> nums = new ArrayList<>(Arrays.asList(1,2,3,3,3,4,5,2,1));
int count = myCount(nums.iterator(), 3);
System.out.println(count);
List<Character> characters =
new ArrayList<>(Arrays.asList('a','b','c','d','e','a','b'));
int count2 = myCount(characters.iterator(), 'a');
System.out.println(count2);
}
}
</syntaxhighlight>
Thanks,
[[User:Vancan1ty|Vancan1ty]] ([[User talk:Vancan1ty|talk]]) 04:35, 19 November 2015 (UTC)
== nested/inner classes ==
I think the article should also state that C++ nested classes differ from Java inner classes.
C++ nested classes are kinda like a static class in Java and can not access fields in the outer class unless they are static (C++11) [[User:Peter.quiring|Peter.quiring]] ([[User talk:Peter.quiring|talk]]) 22:42, 4 April 2016 (UTC)
|