List of Java keywords: Difference between revisions

Content deleted Content added
rewrite/add references for all keywords relating to class member access (and also const keyword)
SmackBot (talk | contribs)
m Date maintenance tags and general fixes
Line 1:
[[Image:Java keywords highlighted.png|thumb|A snippet of Java code with keywords highlighted in blue and bold font]]
 
In the [[Java (programming language)|Java programming language]], a '''keyword''' is one of 50 [[reserved word]]s which have a predefined meaning in the language; because of this, programmers cannot use keywords as names for [[variable#Computer programming|variables]], [[method (computer science)|methods]], [[class (computer science)|classes]], or as any other [[identifier]].<ref name="keywords">{{cite web |title=Java Language Keywords |url=http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html |work=The Java Tutorials |publisher=[[Sun Microsystems, Inc.]] |date=February 14, 2008 |accessdate=2008-12-02}}</ref> Due to their special functions in the language, most [[integrated development environment]]s for Java use [[syntax highlighting]] to display keywords in a different color for easy identification.{{factFact|date=December 2008}}
 
The following is a list of the keywords in Java, along with brief descriptions of their functions:<ref name="keywords" />
Line 69:
:The <code>for</code> keyword is used to create a [[for loop]], which specifies a variable initialization, a [[boolean expression]], and an incrementation. The variable initialization is performed first, and then the boolean expression is evaluated. If the expression evaluates to <code>true</code>, the block of statements assocated with the loop are executed, and then the incrementation is performed. The boolean expression is then evaluated again; this continues until the expression evaluates to <code>false</code>.<ref name="for">{{cite web |title=The for Statement |url=http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html |work=The Java Tutorials |publisher=Sun Microsystems, Inc. |date=February 14, 2008 |accessdate=2008-12-03}}</ref>
 
:As of [[Java version history#J2SE 5.0 (September 30, 2004) (EOL)|J2SE 5.0]],{{factFact|date=December 2008}} the <code>for</code> keyword can also be used to create a so-called "[[for each loop|enhanced for loop]]", which specifies an [[array]] or {{Javadoc:SE|java/lang|Iterable}} object; each iteration of the loop executes the associated block of statements using a different element in the array or Iterable.<ref name="for" />
 
;<code>[[GOTO|goto]]</code>
Line 153:
:The <code>void</code> keyword is used to declare that a method does not return any value.<ref name="return" />
 
:This keyword is also used as a nonfunctional statement.{{factFact|date=December 2008}}
 
;<code>[[Volatile variable|volatile]]</code>