Java syntax: Difference between revisions

Content deleted Content added
Cydebot (talk | contribs)
m Robot - Speedily moving category Java programming language to Category:Java (programming language) per CFDS.
m Typo/general fixing, replaced: vice-versa → vice versa using AWB
Line 4:
The [[syntax]] of the [[Java (programming language)|Java programming language]] is the set of rules defining how a Java program is written and interpreted.
 
The syntax is mostly derived from [[C (programming language)|C]] and [[C++]]. Unlike C++, Java is almost exclusively an [[object-oriented language]]. There are no global functions or variables, all code belongs to [[class (computer science)|class]]es and all values are [[object (computer science)|object]]s. The only exception is the [[primitive type]]s, which are not represented by a class instance due to performance reasons (though can be automatically converted to objects and vice- versa via [[#Boxing and unboxing|autoboxing]]). Some features like [[operator overloading]] or [[unsigned integer]] types are omitted to simplify the language and to avoid possible programming mistakes.
 
'''Java syntax''' is constantly improved in major [[JDK]] [[Java version history|releases]]. The latest improvements to the language happened in Java SE 7, which introduced such language features as [[#try-with-resources statements|<code>try</code>-with-resources statements]] and [[#Literals|binary literals]].
Line 11:
 
===Identifier===
An [[Identifier#In_computer_languagesIn computer languages|identifier]] is the name of an element in the [[source code|code]]. There are certain standard [[Naming conventions (programming)|naming conventions]] to follow when selecting names for elements. Identifiers in Java are [[Case sensitivity|case-sensitive]].
 
An identifier can contain:
Line 1,189:
A direct superinterface (§8.1.5) of C declares or inherits a method (which is therefore necessarily abstract) and C neither declares nor inherits a method that implements it.
 
A subclass of an abstract class that is not itself abstract may be instantiated, resulting in the execution of a constructor for the abstract class and, therefore, the execution of the field initializers for instance variables of that class.
 
<source lang=Java5>
Line 1,411:
{{Main|Generics in Java}}
 
[[Generic programming|Generics]], or parameterized types, or [[Polymorphism_in_objectPolymorphism in object-oriented_programmingoriented programming#Parametric_PolymorphismParametric Polymorphism|parametric polymorphism]] is one of the major features introduced in [[J2SE 5.0]]. Before generics were introduced, it was required to declare all the types explicitly. With generics it became possible to work in a similar manner with different types without declaring the exact types. The main purpose of generics is to ensure type safety and to detect runtime errors during compilation. Unlike C#, information on the used parameters is not available at runtime due to [[type erasure]].
 
===Generic classes===