Abstract
Keywords in a Java language are used in class declaration to indicate that a class cannot be instantiated, but can be inherited by other classes. An abstract class can use abstract methods. abstract methods do not need to be implemented, but must be implemented in subclasses.
Break
A Java keyword used to changeProgramThe execution process starts from the next sentence of the current statement. If there is a tag next to it, it will be executed from where the tag corresponds.
Case
Java keywords are used to define a set of Branch selection. If a value is the same as the value given in the switch, it is executed from this branch.
Catch
A keyword of Java, used to declare a block that runs when a runtime error or non-runtime exception occurs in the try statement block.
Char
A keyword of the Java language used to define a character type.
Continue
A Java keyword used to interrupt the current loop process and re-execute the code from the end of the current loop. If there is a tag next to it, it is executed from where the tag corresponds.
Do
A Java keyword is used to declare a loop. The ending condition of this loop can be set through the while keyword.
Double
A Java keyword used to define a double Type Variable
Else
A keyword in the Java language. If the condition of the IF statement is not met, the statement is executed.
Final
A keyword in Java. You can only define an object once and cannot change or inherit it later. More strictly speaking: A Final-modified class cannot be subverted, a final-modified method cannot be overwritten, and a final-modified variable cannot change its initial value.
Finally
A Java keyword used to executeCodeWhether an exception or running error occurs in the try Statement defined earlier.
Float
A Java keyword used to define a floating point variable.
For
A Java keyword used to declare a loop. Programmers can specify the statements to be cyclic, introduce conditions, and initialize variables.
If
JavaProgramming LanguageIs used to generate a condition test. If the condition is true, the statement under if is executed.
Implements
A keyword of the Java (TM) programming language is optional in the class declaration to specify the interface implemented by the current class.
Import
A keyword of Java (TM) programming language. It specifies a class or the entire package to be referenced later in the start part of the source file, so that the package name does not need to be added during use.
Instanceof
The Java (TM) Language keyword of a Two-operand is used to test whether the runtime type of the first parameter is compatible with the second parameter.
Int
A keyword of Java (TM), used to define an integer variable.
Interface
A keyword of Java (TM), used to define a series of methods and constants. It can be implemented by the class through the implements keyword.
Long
A keyword of the Java language used to define a long type variable.
Private
A keyword of the Java language, used in the sound of a method or variable. It indicates that this method or variable can only be accessed by other elements of this class.
Protected
A keyword of the Java language used in the declaration of methods and variables. It indicates that this method or variable can only be accessed by elements in the same class, subclass, or class in the same package.
.
Public
A keyword of the Java language used in the declaration of methods and variables. It indicates that this method or variable can be accessed by elements in other classes.
Return
A keyword of the Java language used to end the execution of a method. It can be followed by a value required in the method declaration.
Short
A keyword of the Java language used to define a variable of the short type.
Static
A keyword of the Java language used to define a variable as a class variable. The class only maintains a copy of the class variable, no matter how many instances the class currently has. "Static" can also be used to define a method as a class method. A class method is called by class name instead of a specific instance and can only operate class variables.
This
Java keywords are used to represent an instance of the class it appears. This can be used to sort class variables and class methods.
Throw
Java keywords, allowing users to throw an exception object or any object that implements throwable
Throws
Keywords of the Java language are used in the method declaration to indicate which exceptions this method does not handle, but is committed to a higher layer of the program.
Transient
A keyword of the Java language used to indicate that a domain is not a part of the serialization of the object. When an object is serialized, the value of the transient variable is not included in the serialized representation. However, non-transient variables are included.
Try
A keyword in Java to define a block that may throw an exception. If an exception is thrown, an optional Catch Block will handle the exception thrown in the try block. At the same time, a finally statement block is executed, regardless of whether an exception is thrown.
Void
The keyword of the Java language is used in the method declaration of the Java language to indicate that this method does not return any value. "Void" can also be used to indicate a statement without any function.
Volatile
Keywords of the Java language are used in variable declaration to indicate that the variable is modified asynchronously by several threads running at the same time.
While
A keyword of the Java language used to define a repeating statement. The exit condition of the loop is part of the while statement.
About break and continue.
The continue statement is related to the break statement, but is rarely used. The continue statement is used to start the next loop of the For, while, Or do-while statement. In the while and do-while statements, the execution of the continue statement means that the test part is executed immediately. In the for loop statement, the execution of the continue statement means that the control is passed to the incremental part.
Test code
Public Class Labledfor {
// Static test monitor = new test ();
Public Static Void Main (string [] ARGs){
Int I = 0;
Outer:
For (; True {
Inner:
For (; I <10; I ++) {
System. Out. println ( "I =" + I );
If (I = 2) {
System. Out. println ("Continue" );
Continue ;
}
If (I = 3) {
System. Out. println ( "Break" );
I ++;
Break ;
}
If (I = 7) {
System. Out. println ("Continue outer" );
I ++;
Continue Outer;
}
If (I = 8) {
System. Out. println ( "Break outer" );
Break Outer;
}
For ( Int K = 0; k <5; k ++) {
If (K = 3) {
System. Out. println ( "Continue inner" );
Continue Inner;
}
}
}
}
}
}
Result
I = 0
Continue inner
I = 1
Continue inner
I = 2
Break
I = 3
Continue
I = 4
Continue inner
I = 5
Continue inner
I = 6
Continue inner
I = 7
Continue outer
I = 8
Java keywords have not been noticed before, because they are very basic. I just did my scjp question today. I was shocked by the answer and flipped my previous incorrect ideas. After reading a lot of information, I finally figured it out. The questions are as follows:
Which are not Java keywords?
A. True. sizeof C. Const D. Super E. Void
Answer a and B (I have always thought that true and null are also Java keywords, but they are not)
A: No,Java has true, but this is not a keyword but a literal ).
B: No. This operator is not required in Java. The size of all types (original types) is fixed.
C, D, and E are both. Note that const is a keyword not used in Java.
The following is a list of Java keyword categories: (50 in total for your reference)
Access control:
Private
Protected
Public
Class, method, and variable Modifier
Abstract declaration Abstraction
Class
Extends extension and inheritance
Final ultimate, unchangeable
Implements implementation
Interface
Native local
New, create
Static
Strict and accurate strictfp
Synchronized thread, synchronous
Transient is short
Volatile is easy to lose
Program Control statement
Break bounce cycle
Continue
Return
Do run
While Loop
If
Else and vice versa
For Loop
Instanceof instance
Switch
Case: return the result in the switch.
Default
Error Handling
Catch exception
Run any finally exceptions
Throw an exception object
Throws declares that an exception may be thrown.
Try catch exceptions
Package-related
Import
Package
Basic Type
Boolean
Byte type
Char character type
Double double,
Float floating point
Int integer
Long Integer
Short short integer
Variable reference
Super parent class, superclass
This class
Void no return value
Identify keywords in the Java language. Be sure not to confuse them with keywords in other languages such as C/C ++.Const and goto are reserved words in Java.. All keywords are in lowercase,Note that true, false, null, friendly, and sizeof are not Java keywords,But you cannot use them as Java identifiers. Many of my friends may have the same misunderstandings as me, but this is a Java game rule. I believe it only after checking Sun's official explanation. Remember that true, false, and null in Java are neither keywords nor reserved words. They are only explicit constant values, but they cannot be used as identifiers in programs. Why? I don't know, but this is Sun's Java rule. You cannot play games that don't want to follow its rules.
Refer to the URL
Http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
To make it easier for me to copy it directly, the original method is as follows:
Java language keywords
Here's a list of keywords in the Java programming language. you cannot use any of the following as identifiers in your programs. the keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.
|
Abstract |
Continue |
For |
New |
Switch |
|
Assert *** |
Default |
Goto * |
Package |
Synchronized |
|
Boolean |
Do |
If |
Private |
This |
|
Break |
Double |
Implements |
Protected |
Throw |
|
Byte |
Else |
Import |
Public |
Throws |
|
Case |
Enum **** |
Instanceof |
Return |
Transient |
|
Catch |
Extends |
Int |
Short |
Try |
|
Char |
Final |
Interface |
Static |
Void |
|
Class |
Finally |
Long |
Strictfp ** |
Volatile |
|
Const * |
Float |
Native |
Super |
While |
|
* |
|
not used |
|
** |
|
added in 1.2 |
|
*** |
|
added in 1.4 |
|
***** |
|
added in 5.0 |