Content deleted Content added
wrap keywords in <code></code> |
rewrite/add references for all keywords relating to variable/method return type declaration |
||
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.]] |
The following is a list of the keywords in Java, along with a brief description of their functions:<ref name="keywords" />
Line 12:
;<code>[[Boolean datatype#Java|boolean]]</code>
:The <code>boolean</code> keyword is used to declare a [[field (computer science)|field]] that can store a [[boolean datatype|boolean value]]; that is, either <code>true</code> or <code>false</code>.<ref name="primitive">{{cite web |title=Primitive Data Types |url=http://java.sun.com/docs/books/tutorial/java/nutsandbolts/datatypes.html |work=The Java Tutorials |publisher=Sun Microsystems, Inc. |date=February 14, 2008 |accessdate=2008-12-03}}</ref>
:This keyword is also be used to declare that a method returns a value of type <code>boolean</code>.<ref name="return">{{cite web |title=Returning a Value from a Method |url=http://java.sun.com/docs/books/tutorial/java/javaOO/returnvalue.html |work=The Java Tutorials |publisher=Sun Microsystems, Inc. |date=February 14, 2008 |accessdate=2008-12-03}}</ref>
;<code>[[Switch statement#Java|break]]</code>
Line 18 ⟶ 20:
;<code>[[byte]]</code>
:The <code>byte</code> keyword is used to declare a field that can store an 8-[[bit]] signed [[two's complement]] integer.<ref name="primitive" />
:This keyword is also be used to declare that a method returns a value of type <code>byte</code>.<ref name="return" />
;<code>[[Switch statement#Java|case]]</code>
Line 27 ⟶ 31:
;<code>[[Character (computing)|char]]</code>
:
:This keyword is also be used to declare that a method returns a value of type <code>char</code>.<ref name="return" />
;<code>[[Class (computer science)#Java|class]]</code>
Line 45 ⟶ 51:
;<code>[[Double precision|double]]</code>
:
:This keyword is also used to declare that a method returns a value of type <code>double</code>.<ref name="return" />
;<code>[[Conditional statement|else]]</code>
Line 63 ⟶ 71:
:Used to define a block of statements for a block defined previously by the <code>try</code> keyword. The <code>finally</code> block is executed after execution exits the <code>try</code> block and any associated <code>catch</code> clauses regardless of whether an exception was thrown or caught, or execution left method in the middle of the <code>try</code> or <code>catch</code> blocks using the <code>return</code> keyword.
;<code>[[
:
:This keyword is also used to declare that a method returns a value of type <code>float</code>.<ref name="return" />
;<code>[[for loop#Java|for]]</code>
:Used to define a loop that reiterates statements. The <code>for</code> loop specifies the statements to be executed, exit condition, and initialization variables for the loop. The exit condition is evaluated before the first iteration of the loop. Since J2SE 5.0, a form of the <code>for</code> loop specifies an {{Javadoc:SE|java/lang|Iterable}} object where each iteration of the loop processes one of its contained elements.
;<code>[[GOTO|goto]]</code> (reserved without use)
:This keyword is '''not used''' by current versions of the Java programming language.
Line 85 ⟶ 95:
;<code>[[Integer (computer science)|int]]</code>
:
:This keyword is also used to declare that a method returns a value of type <code>int</code>.<ref name="return" />
;<code>[[Interface (Java)|interface]]</code>
Line 91 ⟶ 103:
;<code>[[long integer|long]]</code>
:
:This keyword is also used to declare that a method returns a value of type <code>long</code>.<ref name="return" />
;<code>native</code>
Line 115 ⟶ 129:
;<code>[[short integer|short]]</code>
:
:This keyword is also used to declare that a method returns a value of type <code>short</code>.<ref name="return" />
;<code>[[Static variable|static]]</code>
Line 149 ⟶ 165:
;<code>[[void return type|void]]</code>
:
:This keyword is also used as a nonfunctional statement.{{fact}}
;<code>[[Volatile variable|volatile]]</code>
Line 169 ⟶ 187:
== References ==
;General
*{{cite
;Footnotes
{{reflist|2}}
[[Category:Java programming language]]
|