Skip to content

Commit 7ecdef0

Browse files
hal-eisen-adfaHal Eisen
andauthored
Fix missing java_keywords.html (#13)
Co-authored-by: Hal Eisen <haleisen@appdeforall.org>
1 parent 1849e52 commit 7ecdef0

1 file changed

Lines changed: 285 additions & 0 deletions

File tree

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<script src="toggle.js"></script>
5+
<link rel="stylesheet" href="style.css">
6+
<p>Java reserves the following keywords. This page is based on content from Wikipedia (https://en.wikipedia.org/wiki/List_of_Java_keywords) and from LOCAL LINK Java, Java, Java:
7+
Object-Oriented Problem Solving by Ralph Morelli, Ralph Walde, and Beryl Hoffman. LOCAL LINK
8+
9+
10+
<table border="1" width="100%" style="font-size: 12px;">
11+
<tr><!-- Row 1 -->
12+
<th style="width:10%;">Java keyword</td><!-- Col 1 -->
13+
<th style="width:90%;">Description</td><!-- Col 2 -->
14+
15+
</tr>
16+
<tr><!-- Row 2 -->
17+
<td><a name="abstract"><code>abstract</code></a></td><!-- Col 1 -->
18+
<td>A method with no definition must be declared as <code>abstract</code> and the class containing it must be declared as abstract Abstract classes cannot be instantiated. Abstract methods must be implemented in the subclasses. <code>Abstract</code> cannot be used with variables or constructors. Note that an abstract class is not required to have an abstract method.
19+
20+
[WIKIPEDIA]
21+
22+
</td><!-- Col 3 -->
23+
</tr>
24+
<tr><!-- Row 3 -->
25+
<td><code><a name="assert"><code>assert</code></a></td><!-- Col 1 -->
26+
<td><code>assert</code> describes a predicate placed in a Java program to indicate that the developer thinks that a true/false statement is true and must always be true at that place. <code>Assert</code> describes a predicate (a true-false statement (called a predicate) placed in a Java program that to indicates that the developer thinks that the predicate is always true at that place. If an assertion evaluates to false at run-time, an assertion failure results, which typically causes execution to abort.
27+
<pre>
28+
// A person's first name should not be null and execution should abort if it is.
29+
Name firstName = person.getFirstName();
30+
assert firstName != null;
31+
doSomething(firstName);
32+
</pre>
33+
34+
35+
</td><!-- Col 3 -->
36+
</tr>
37+
<tr><!-- Row 4 -->
38+
<td><a name="boolean"><code>boolean</code></a></td><!-- Col 1 -->
39+
<td>Defines a Boolean variable for the values "true" or "false" only. Defines a Boolean variable for the values "true" or "false" only. By default, the value of the boolean primitive type is false. This keyword is also used to declare that a method returns a value of the primitive type boolean.
40+
[WIKIPEDIA]
41+
42+
</td>
43+
44+
</tr>
45+
<tr><td><a name="break"><code>break</code></a></td>
46+
<td>Ends the execution in the current loop body or breaks out of a switch block. For loop example:
47+
This code loops through an array and prints each element. When it encounters the value 5, the loop terminates and does not print this value. <pre>
48+
int[] = {1, 2, 5, 10}
49+
for (k=0;k < arr.length; k++)
50+
if (arr[k] == 5)
51+
</pre>
52+
</td> </tr>
53+
54+
</tr>
55+
<tr><td><a name="byte"><code>byte</code></a></td>
56+
<td>Used in conjunction with a try block and an optional finally block. The statements in the catch block specify what to do if the try block throws a specific type of exception.
57+
58+
</td> </tr>
59+
60+
61+
</tr>
62+
63+
<tr><td><a name="case"><code>case</code></a></td>
64+
<td>A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluates its expression, then executes all statements that follow the matching case label.
65+
66+
</td>
67+
<tr><td><a name="char"><code>char</code></a></td>
68+
<td>A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluates its expression, then executes all statements that follow the matching case label.</td> </tr>
69+
70+
</tr>
71+
<a name="class"> <tr><td><code>class</code></td></a>
72+
<td>A class definition contains variables that store the object's information and methods that process the information. A defined class acts as a template to create individual objects or instances of the class.
73+
</td></tr> <tr><td><code>const</code>*</td>
74+
<td>This keyword is reserved for potential use in the future.
75+
</td></tr>
76+
77+
<tr><td><a name="continue"><code>continue</code></a></td>
78+
<td>Resumes program execution at the end of the current loop body. If followed by a label, continue resumes execution at the end of the enclosing labeled loop body.
79+
<p>This code loops through an array and prints each value. When it encounters the value 5, it skips the print statement and resumes the for loop at the next value. </p> <pre>
80+
// Prints:
81+
// 1
82+
// 2
83+
// 10
84+
int[] arr = {1, 2, 5, 10}
85+
for (k = 0; k < arr.length; k++)
86+
if (arr[k] == 5)
87+
continue;
88+
System.out.println(arr[k]);
89+
</pre>
90+
</td> </tr>
91+
92+
93+
94+
<tr><td><a name="default"><code>default</code></a></td><td>The <code>default</code> keyword can optionally be used in a switch statement to label a block of statements to be executed if no case matches the specified value; see switch.[9][10] Alternatively, the default keyword can also be used to declare default values in a Java annotation. From Java 8 onwards, the default keyword can be used to allow an interface to provide an implementation of a method. </td>
95+
96+
<tr><td><a name="do"><code>do</code></a></td><td>The <code>do</code> keyword is used in conjunction with while to create a do-while loop, which executes a block of statements associated with the loop and then tests a boolean expression associated with the <code>while</code>. If the expression evaluates to true, the block is executed again; this continues until the expression evaluates to false. </td>
97+
98+
99+
<tr><td><a name="double"><code>double</code></a></td><td>The <code>double</code> keyword is used to declare a variable that can hold a 64-bit double precision IEEE 754 floating-point number. This keyword is also used to declare that a method returns a value of the primitive type double. Can take on double precision values from -1.79769313486231570e+308 to +1.79769313486231570e+308 </td>
100+
<tr><td><a name="extends"><code>extends<code></a></td><td>Class X extends class Y to add functionality by adding fields or methods to class Y, or by overriding methods of class Y. When used in an interface declaration, an interface Z extends one or more interfaces by adding methods. Z is said to be a subinterface of the interfaces it extends. Also used to specify an upper bound on a type parameter in Generics. (elements that are not classes and cannot be further expanded)
101+
102+
</td></tr>
103+
104+
<tr><td><a name="final"><code>final</code></td><td> Defines an entity once that cannot later be changed nor derived from. A final class cannot be subclassed. A final method cannot be overridden. A final variable can occur at most once as a left-hand expression on an executed command. All methods in a final class are implicitly final.
105+
106+
</td></tr>
107+
108+
109+
<tr><td><a name="finally"><code>finally</code></td><td> Used to define a block of statements for a block defined previously by the <code>try</code> keyword. The finally block is executed after execution exits the <code>try</code> block and any associated catch clauses regardless of whether an exception was thrown or caught, or execution left method in the middle of the try or catch blocks using the <code>return</code> keyword.
110+
111+
</td></tr>
112+
113+
<tr><td><a name="finally"><code>finally</code></td><td> Used to define a block of statements for a block defined previously by the <code>try</code> keyword. The finally block is executed after execution exits the <code>try</code> block and any associated catch clauses regardless of whether an exception was thrown or caught, or execution left method in the middle of the try or catch blocks using the <code>return</code> keyword.
114+
115+
</td></tr>
116+
117+
118+
<tr><td><a name="float"><code>float</code></td><td> The <code>float</code> keyword is used to declare a variable that can hold a 32-bit single precision IEEE 754 floating-point number. This keyword is also used to declare that a method returns a value of the primitive type float. Can take single-precision values from <b>-3.40292347e+38</b> to <b>3.40292347e+38 </b>
119+
</td></tr>
120+
121+
<tr><td><a name="for"><code>for</code></td><td> The <code>for</code> keyword is used to create a <code>for</code> 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 true, the block of statements associated 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>.
122+
</td></tr>
123+
124+
<tr><td><a name="goto">goto*</td><td> This keyword is reserved for potential use in the future.
125+
</td></tr>
126+
127+
<tr><td><a name="if"><code>if</code></td><td> Used to create an <code>if</code> statement that tests a Boolean expression.
128+
If the expression evaluates to <code>true</code>, the block of statements associated with the if statement is executed. This keyword can also be used to create an <code>if-else</code> statement; see <code>else</code>
129+
130+
131+
<tr><td><a name="implements"><code>implements</code></td><td> Included in a class declaration to specify one or more interfaces that are implemented by the current class. A class inherits the types and abstract methods declared by the interfaces.
132+
133+
</td></tr>
134+
<tr><td>
135+
<a name="import"><code>import</code></td><td>Used to create an <code>if</code> statement that tests a Boolean expression. If the expression evaluates to <code>true</code>, the block of statements associated with the <code>if</code> statement is executed. This keyword can also be used to create an <code>if-else</code> statement; see <code>else</code>.
136+
</td></tr>
137+
138+
<tr><td><a name="instanceof"><code>instanceof</code></td><td>A binary operator that is used to check if the runtime type of an object is assignment-compatible with a particular class or interface. <code>instanceof</code> takes an object reference as its first operand, takes class or interface as its second operand, and produces a Boolean result.
139+
The <code>instanceof</code> operator evaluates to true if and only if the object's runtime type is assignment-compatible with the class or interface.
140+
141+
</td></tr>
142+
143+
<tr><td>
144+
<a name="int"><code>int</code></td><td>Used to declare a variable that can hold a 32-bit signed two's complement integer.This keyword is also used to declare that a method returns a value of the primitive type int.<br>
145+
Can take on values from <b>-2^31</b> to <b>2^31 - 1</b>
146+
147+
</td></tr>
148+
149+
<tr><td>
150+
<a name="interface"><code>interface</code></td><td> Used to declare a special type of class that only contains abstract or default methods, constant (<code>static final</code>) fields, and <code>static</code> interfaces. It can later be implemented by classes that declare the interface with the implements keyword. As multiple inheritance is not allowed in Java, interfaces are used to circumvent this limitationit. An interface can be defined within another interface.
151+
152+
</td></tr>
153+
154+
<tr><td>
155+
<a name="long"><code>long</code></td><td>The long keyword is used to declare a variable that can hold a 64-bit signed two's complement integer.This keyword is also used to declare that a method returns a value of the primitive type <code>long</code>.<br>
156+
Can take on values from<b> -2^63</b> to <b>2^63 - 1</b>
157+
158+
</td></tr>
159+
<tr><td>
160+
161+
<a name="native"><code>native</code></td><td> Used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language.
162+
163+
</td></tr>
164+
<tr><td>
165+
166+
<a name="new"><code>new</code></td><td>Used to create an instance of a class or array object.
167+
168+
</td></tr>
169+
170+
<tr><td>
171+
172+
<a name="package"><code>package</code></td><td> A package contains inter-related classes.
173+
All classes must belong to a package. Java places classes without a package statement into an unnamed default package.
174+
175+
</td></tr>
176+
177+
<tr><td>
178+
179+
<a name="private"><code>private</code></td><td> The <code>private</code> keyword is used in the declaration of a method, field, or inner class. Private members can only be accessed by other members of their own class.
180+
181+
</td></tr>
182+
183+
<tr><td>
184+
185+
<a name="protected"><code>protected</code></td><td> The <code>protected</code> keyword is used in the declaration of a method, field, or inner class.
186+
Protected members can only be accessed by members of their own class, that class's subclasses, or classes from the same package.
187+
</td></tr>
188+
189+
190+
191+
<tr><td>
192+
193+
<a name="public"><code>public</code></td><td>The <code>public</code> keyword is used in the declaration of a class, method, or field. Public classes, methods, and fields can be accessed by the members of any class.
194+
195+
196+
</td></tr>
197+
198+
199+
<tr><td>
200+
201+
<a name="return"><code>return</code></td><td> Used to fnish the execution of a method.
202+
It can be followed by a value required by the method definition that is returned to the caller.
203+
204+
</td></tr>
205+
206+
207+
208+
<tr><td>
209+
210+
<a name="short"><code>short</code></td><td> The <code>short</code> keyword is used to declare a field that can hold a 16-bit signed two's complement integer. This keyword is also used to declare that a method returns a value of the primitive type <code>short</code>. Can take on values from <b>X</b> to <b>Y</b>
211+
</td></tr>
212+
213+
214+
215+
<tr><td>
216+
217+
<a name="static"><code>static</code></td><td> Used to declare a field, method, or inner class as a class field. Classes maintain one copy of class fields regardless of how many instances exist of that class. <code>static</code> also is used to define a method as a class method. Class methods are bound to the class instead of to a specific instance, and can only operate on class fields. Classes and interfaces declared as <code>static</code> members of another class or interface are behaviorally top-level classes.
218+
219+
</td></tr>
220+
221+
<tr><td>
222+
<a name="strictfp"><code>strictfp</code></td><td> <code>strictfp</code> is an obsolete and redundant reserved word.
223+
224+
</td></tr>
225+
226+
<tr><td>
227+
228+
<a name="super"><code>super</code></td><td>Inheritance specifier used to achieve dynamic binding or run-time polymorphism in Java. Used to access members of a class inherited by the class in which it appears. Allows a subclass to access overridden methods and hidden members of its superclass. The <code>super</code> keyword is also used to forward a call from a constructor to a constructor in the superclass. Also used to specify a lower bound on a type parameter in Generics.
229+
230+
</td></tr>
231+
232+
<tr><td>
233+
234+
<a name="switch"><code>switch</code></td><td>The <code>switch</code> keyword is used in conjunction with <code>case</code> and <code>default</code> to create a switch statement. The switch statement evaluates a variable, matches its value to a specific <code>case</code>, and executes the block of statements associated with that <code>case</code>. If no <code>case</code> matches the value, the optional block labeled by <code>default</code> is executed if it is included.
235+
</td></tr>
236+
237+
<tr><td>
238+
239+
<a name="synchronized"><code>synchronized</code></td><td>Used in the declaration of a method or code block to acquire the mutex lock for an object while the current thread executes the code. For static methods, the object locked is the class's <code>Class</code>. Guarantees that at most one thread at a time operating on the same object executes that code. The mutex lock is automatically released when execution exits the synchronized code. Fields, classes and interfaces cannot be declared as <code>synchronized</code>.
240+
</td></tr>
241+
242+
243+
<tr><td>
244+
245+
<a name="this"><code>this</code></td><td> Used to represent an instance of the class in which it appears. The keyword <code>this</code> can be used to access class members and as a reference to the current instance. The keyword is also used to forward a call from one construct in a class to another constructor in the same class.
246+
</td></tr>
247+
248+
<tr><td>
249+
250+
<a name="throw"><code>throw</code></td><td> Causes the declared exception instance to be thrown. This causes execution to continue with the first enclosing exception handler declared by the <code>catch</code> keyword to handle an assignment compatible exception type. If no such exception handler is found in the current method, then the method returns and the process is repeated in the calling method. If no exception handler is found in any method call on the stack, then the exception is passed to the thread's uncaught exception handler.
251+
</td></tr>
252+
253+
<tr><td>
254+
255+
<a name="throws"><code>throws</code></td><td>Used in method declarations to specify which exceptions are not handled within the method but rather passed to the next higher level of the program. All uncaught exceptions in a method that are not instances of <code>RuntimeException</code> must be declared using the <code>throws</code> keyword.
256+
257+
</td></tr>
258+
259+
<tr><td>
260+
<a name="transient"><code>transient</code></td><td> Declares that an instance field is not part of the default serialized form of an object. When an object is serialized, only the values of its non-transient instance fields are included in the default serial representation. When an object is deserialized, transient fields are initialized only to their default value. If the default form is not used, e.g. when a <i>serialPersistentFields</i> table is declared in the class hierarchy, all <code>transient</code> keywords are ignored.
261+
262+
</td></tr>
263+
264+
<tr><td>
265+
<a name="try"><code>try</code></td><td> Defines a block of statements that have exception handling. If an exception is thrown inside the <code>try</code> block, an optional <code>catch</code> block can handle declared exception types. Also, an optional finally block can be declared that will be executed when execution exits the <code>try</code> block and <code>catch</code> clauses, regardless of whether an exception is thrown or not. A try block must have at least one <code>catch</code> clause or a <code>finally</code> block.
266+
</td></tr>
267+
268+
<tr><td>
269+
<a name="void"><code>void</code></td><td> Used to declare that a method does not return any value.
270+
271+
272+
</td></tr>
273+
274+
<tr><td>
275+
<a name="volatile"><code>volatile</code></td><td> Used in field declarations to guarantee visibility of changes to variables across threads. Every read of a volatile variable will be read from main memory, and not from the CPU cache, and that every write to a volatile variable will be written to main memory, and not just to the CPU cache. Methods, classes and interfaces thus cannot be declared volatile, nor can local variables or parameters.
276+
277+
</td></tr>
278+
<tr><td>
279+
<a name="while"><code>while</code></td><td> Used to create a while loop, which tests a Boolean expression and executes the block of statements associated with the loop if the expression evaluates to <code>true</code>. This continues until the expression evaluates to <code>false</code>. This keyword can also be used to create a do-while loop,
280+
</td></tr>
281+
282+
</table>
283+
284+
</body>
285+
</html>

0 commit comments

Comments
 (0)