Talk:Comparison of C Sharp and Java/Archive 1: Difference between revisions

Content deleted Content added
MalnadachBot (talk | contribs)
m Fixed Lint errors. (Task 12)
syntaxhighlight & fix lint
 
Line 98:
In Java 5.0 enums are lower case, like types, and have their own syntax.
 
<syntaxhighlight lang="java">
<code>
private enum Coin {
penny(1), nickel(5), dime(10), quarter(25);
Line 105:
public int value() { return value; }
}
</syntaxhighlight>
</code>
 
Also enums can be used in switches. Classes cannot be used this way.
 
<syntaxhighlight lang="java">
<code>
switch(menu) {
case FILE:
Line 124:
break;
}
</syntaxhighlight>
</code>
 
Check out
Line 133:
In Java even arrays are technically classes ie
 
<syntaxhighlight lang="java">
<code>
Object o = new int[10];
</syntaxhighlight>
</code>
same in c# --[[User:Motherofinvention|Motherofinvention]] 01:05, 29 June 2006 (UTC)
Further compiling:
 
<syntaxhighlight lang="C#">
<code>
public class Test {
private int enum = 10;
}
</syntaxhighlight>
</code>
 
Yields the error:
 
<code>
Test.java:2: as of release 1.5, 'enum' is a keyword, and may not be used as an identifier
(try -source 1.4 or lower to use 'enum' as an identifier)
Line 153 ⟶ 152:
^
1 error
</code>
 
My inclination is to call it a keyword, because of the new syntax, and the compiler error.
[[User:Tbjablin|Tbjablin]] 04:34, 9 Mar 2005 (UTC)
: Yeah, it seems pretty clear that <code>enum</ttcode> is a keyword in Java. [[User:Neilc|Neilc]] 01:08, 10 Mar 2005 (UTC)
 
Keyword or not, <code>enum</code> is a feature of all (or nearly all?) programming languages in the C language family, and as such is uninteresting in this context. I've deleted the reference, hope that's OK... [[User:GregorB|GregorB]] 12:37, Apr 29, 2005 (UTC)