Java 키워드 목록 - List of Java keywords
에서 자바 프로그래밍 언어 하는 키워드 (52) 중 어느 하나 인 예약어는 [1] 언어에서 미리 정의 된 의미를 갖는 것; 이 때문에, 프로그래머의 이름으로 키워드를 사용할 수 없습니다 변수 , 메소드 , 클래스 , 또는 다른 식별자 . [2] 이 (52 개)의 키워드, 49 (1)에 미리, 사용하고, (2)는 사용되지 않는다. 때문에 언어에서의 특별한 기능으로, 대부분의 통합 개발 환경에서 자바 사용을위한 구문 강조 쉽게 식별 할 수 있도록 다른 색으로 키워드를 표시합니다.
명부
_
- Java 9에 추가 된 밑줄은 키워드가되었으며 더 이상 변수 이름으로 사용할 수 없습니다. [삼]
abstract
- 정의가없는 메소드는 추상으로 선언되어야하며이를 포함하는 클래스는 추상으로 선언되어야합니다. 추상 클래스는 인스턴스화 할 수 없습니다. 추상 메서드는 하위 클래스에서 구현되어야합니다. 추상 키워드는 변수 또는 생성자와 함께 사용할 수 없습니다. 추상 클래스에는 추상 메서드가 전혀 필요하지 않습니다.
-
assert
(첨가 J2SE 1.4 ) [4] - Assert는 Java 프로그램에 배치 된 술어 (true-false 문)를 설명하여 개발자가 술어가 항상 해당 위치에서 참이라고 생각 함을 나타냅니다. 런타임에서 false로 주장의 평가되면, 일반적으로 중단 실행을 일으키는 어설 션 오류 결과. 선택적으로 ClassLoader 메서드로 활성화합니다.
boolean
-
값이 "true"또는 "false"만을위한 부울 변수를 정의합니다. 기본적으로 부울 기본 유형의 값은 false입니다. 이 키워드는 또한 방법은 원시적 형의 값을 반환한다는 것을 선언하는 데 사용됩니다
boolean
.
break
- 현재 루프 본문에서 실행을 종료하는 데 사용됩니다.
byte
-
byte
키워드는 8 비트는 2의 보수 부호있는 정수 보유 할 수있는 필드를 선언하는 데 사용됩니다. [5] [6] 이 키워드는 메서드가 기본 유형의 값을 반환 함을 선언하는데도 사용됩니다byte
. [7] [8]
-
case
-
에있는 문
switch
블록은 하나 이상으로 표시 할 수case
또는default
라벨.switch
문은 일치에 따라 모든 명령문 실행, 그 표현식을 평가case
라벨을; 참조하십시오switch
. [9] [10]
catch
-
try
블록 및 옵션finally
블록 과 함께 사용됩니다 . 의 문catch
블록은 예외의 특정 유형에 의해 발생되는 경우에 수행 할 작업을 지정합니다try
블록.
char
- 자바 소스 파일의 문자 집합의 모든 문자를 보유 할 수있는 문자 변수를 정의합니다.
class
-
객체의 특정 종류의 구현을 정의하는 유형입니다. 클래스 정의는 정의 인스턴스 와 클래스 필드 , 방법 및 내부 클래스 뿐만 아니라 지정하는 것과 인터페이스 클래스 구현 즉시 수퍼 클래스를. 슈퍼 클래스가 명시 적으로 지정되지 않은 경우, 슈퍼 클래스는 암시 적이다
Object
. class 키워드는 Class .class 형식으로도 사용되어 해당 클래스 의 인스턴스없이 Class 객체를 가져올 수 있습니다. 예를 들어, new String (). getClass () 대신 String.class를 사용할 수 있습니다 .
const
- 미사용이지만 예약되어 있습니다.
continue
- Used to resume 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.
-
default
- The
default
keyword can optionally be used in a switch statement to label a block of statements to be executed if nocase
matches the specified value; seeswitch
.[9][10] Alternatively, thedefault
keyword can also be used to declare default values in a Java annotation. From Java 8 onwards, thedefault
keyword can be used to allow an interface to provide an implementation of a method.
-
do
- The
do
keyword is used in conjunction withwhile
to create a do-while loop, which executes a block of statements associated with the loop and then tests a boolean expression associated with thewhile
. If the expression evaluates totrue
, the block is executed again; this continues until the expression evaluates tofalse
.[11][12]
double
- The
double
keyword is used to declare a variable that can hold a 64-bit double precision IEEE 754 floating-point number.[5][6] This keyword is also used to declare that a method returns a value of the primitive typedouble
.[7][8]
-
else
- The
else
keyword is used in conjunction withif
to create an if-else statement, which tests a boolean expression; if the expression evaluates totrue
, the block of statements associated with theif
are evaluated; if it evaluates tofalse
, the block of statements associated with theelse
are evaluated.[13][14]
-
enum
(added in J2SE 5.0)[4] - A Java keyword used to declare an enumerated type. Enumerations extend the base class
Enum
.
extends
- Used in a class declaration to specify the superclass; used in an interface declaration to specify one or more superinterfaces. Class X extends class Y to add functionality, either by adding fields or methods to class Y, or by overriding methods of class Y. An interface Z extends one or more interfaces by adding methods. Class X is said to be a subclass of class Y; Interface 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.
final
- Define an entity once that cannot be changed nor derived from later. More specifically: a final class cannot be subclassed, a final method cannot be overridden, and 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
.
finally
- Used to define a block of statements for a block defined previously by the
try
keyword. Thefinally
block is executed after execution exits thetry
block and any associatedcatch
clauses regardless of whether an exception was thrown or caught, or execution left method in the middle of thetry
orcatch
blocks using thereturn
keyword.
float
- The
float
keyword is used to declare a variable that can hold a 32-bit single precision IEEE 754 floating-point number.[5][6] This keyword is also used to declare that a method returns a value of the primitive typefloat
.[7][8]
for
- The
for
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 totrue
, 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 tofalse
.[15]
- As of J2SE 5.0, the
for
keyword can also be used to create a so-called "enhanced for loop",[16] which specifies an array orIterable
object; each iteration of the loop executes the associated block of statements using a different element in the array orIterable
.[15]
goto
- Unused
-
if
- The
if
keyword is used to create an if statement, which tests a boolean expression; if the expression evaluates totrue
, the block of statements associated with the if statement is executed. This keyword can also be used to create an if-else statement; seeelse
.[13][14]
implements
- 현재 클래스에 의해 구현되는 하나 이상의 인터페이스 를 지정하기 위해 클래스 선언에 포함됩니다 . 클래스는 유형과 인터페이스에 의해 선언 된 추상 메소드를 상속합니다.
-
import
-
a의 시작 부분에 사용 된 소스 파일을 클래스 나 전체를 지정하는 Java 패키지를 참조 자신의 패키지 이름을 포함하지 않고 나중에 언급한다. J2SE 5.0부터
import
명령문은static
클래스의 멤버를 가져올 수 있습니다 .
instanceof
-
이진 연산자 첫 번째 피연산자 피연산자 클래스 또는 인터페이스와 같은 객체 참조를 취하고 부울 결과를 생성한다.
instanceof
에 운영자들을 평가하는 경우는 true와 객체의 실행시의 형태가 클래스 또는 인터페이스와 호환 할당이있는 경우에만.
int
-
int
키워드는 32 비트 2의 보수 부호있는 정수 보유 할 수있는 변수를 선언하는 데 사용됩니다. [5] [6] 이 키워드는 메서드가 기본 유형의 값을 반환 함을 선언하는데도 사용됩니다int
. [7] [8]
interface
-
단지 추상적 인 또는 기본 방법, 상수 (포함 클래스의 특별한 유형 선언하는 데 사용
static final
) 필드와static
인터페이스를. 나중에implements
키워드로 인터페이스를 선언하는 클래스에서 구현할 수 있습니다 . 다중 상속은 자바에서 허용되지 않기 때문에, 인터페이스를 우회하는 데 사용됩니다. 인터페이스는 다른 인터페이스에서 정의 할 수 있습니다.
long
-
long
키워드는 64 비트 2의 보수 부호있는 정수 보유 할 수있는 변수를 선언하는 데 사용됩니다. [5] [6] 이 키워드는 메서드가 기본 유형의 값을 반환 함을 선언하는데도 사용됩니다long
. [7] [8]
-
new
- Used to create an instance of a class or array object. Using keyword for this end is not completely necessary (as exemplified by Scala), though it serves two purposes: it enables the existence of different namespace for methods and class names, it defines statically and locally that a fresh object is indeed created, and of what runtime type it is (arguably introducing dependency into the code).
non-sealed
- Used to declare that a class or interface which extends a sealed class can be extended by unknown classes.[17]
package
- Java package is a group of similar classes and interfaces. Packages are declared with the
package
keyword.
protected
-
protected
키워드 방법, 필드 또는 내부 클래스의 선언에 사용된다; 보호 된 멤버는 자신의 클래스, 해당 클래스의 하위 클래스 또는 동일한 패키지 의 클래스의 멤버 만 액세스 할 수 있습니다 . [18]
return
- 메서드 실행을 완료하는 데 사용됩니다. 이것은 호출자에게 리턴되는 방법을 정의하여 필요한 값을 이어 할 수있다.
short
-
short
키워드는 16 비트 2의 보수 부호있는 정수 보유 할 수있는 필드를 선언하는 데 사용됩니다. [5] [6] 이 키워드는 메서드가 기본 유형의 값을 반환 함을 선언하는데도 사용됩니다short
. [7] [8]
static
-
클래스 필드로 필드, 메서드 또는 내부 클래스를 선언하는 데 사용됩니다. 클래스는 클래스 필드의 사본에 관계없이 그 클래스의 존재 얼마나 많은 인스턴스를 유지합니다.
static
또한 메서드를 클래스 메서드로 정의하는 데 사용됩니다. 수업 방법은 바인딩 특정 인스턴스 클래스에 대신에, 단지 클래스 필드에서 작동 할 수 있습니다. (클래스 및 인터페이스 선언static
다른 클래스의 구성원 또는 인터페이스 실제로 최상위 클래스이다되어 있지 내부 클래스).
super
-
상속은 기본적으로 자바에서 동적 바인딩 또는 런타임 다형성을 달성하는 데 사용됩니다. 표시되는 클래스에서 상속 된 클래스의 멤버에 액세스하는 데 사용됩니다. 액세스 서브 클래스 수 있습니다 오버라이드 (override) 방법과 슈퍼 클래스의 숨겨진 멤버를.
super
키워드는 슈퍼 클래스의 생성자 생성자에서 전화를 전달하는 데 사용됩니다. - 또한 제네릭의 형식 매개 변수에 하한을 지정하는 데 사용됩니다.
-
switch
- The
switch
keyword is used in conjunction withcase
anddefault
to create a switch statement, which evaluates a variable, matches its value to a specificcase
, and executes the block of statements associated with thatcase
. If nocase
matches the value, the optional block labelled bydefault
is executed, if included.[9][10]
-
synchronized
-
방법 또는 코드 블록의 선언에 사용하면 취득 뮤텍스 현재 중에 오브젝트 잠금 스레드 코드를 실행한다. [8] 정적 메소드를 들어, 고정 대상물의 클래스이다
Class
. 한 번에 최대 하나 개의 스레드가 코드가 동일한 개체가 실행에서 작동하는 것을 보장한다. 뮤텍스 잠금은 실행이 동기화 된 코드를 종료 할 때 자동으로 해제됩니다. 필드, 클래스 및 인터페이스는 동기화 된 것으로 선언 할 수 없습니다 .
this
-
나타나는 클래스의 인스턴스를 나타내는 데 사용됩니다.
this
클래스 멤버에 액세스하고 현재 인스턴스에 대한 참조로 사용할 수 있습니다.this
키워드는 같은 클래스의 다른 생성자에 클래스에서 하나의 생성자에서 전화를 전달하는 데 사용됩니다.
throw
- Causes the declared exception instance to be thrown. This causes execution to continue with the first enclosing exception handler declared by the
catch
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.
throws
- 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
RuntimeException
must be declared using thethrows
keyword.
transient
- 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 serialPersistentFields table is declared in the class hierarchy, all
transient
keywords are ignored.[19][20]
try
-
예외 처리가 문장 블록을 정의합니다. 예외는 내부에 발생하는 경우
try
블록, 선택catch
블록은 예외 유형을 선언 처리 할 수 있습니다. 또한 예외 발생 여부에 관계없이finally
실행이try
블록 및catch
절을 종료 할 때 실행 되는 선택적 블록을 선언 할 수 있습니다 .try
블록은 적어도 하나 있어야합니다catch
절 또는finally
블록을.
volatile
- 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.[21] Methods, classes and interfaces thus cannot be declared volatile, nor can local variables or parameters.
-
while
- The
while
keyword is 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 totrue
; this continues until the expression evaluates tofalse
. This keyword can also be used to create a do-while loop; seedo
.[11][12]
Reserved Identifiers
The following identifiers are not keywords, however they are restricted in some contexts:
permits
- The permits clause specifies the classes that are permitted to extend a sealed class.[22]
record
sealed
- A sealed class or interface can only be extended or implemented only by classes and interfaces permitted to do so.[23]
var
- A special identifier that cannot be used as a type name (since Java 10).[24]
yield
- Used to set a value for a switch expression
Reserved words for literal values
true
- A boolean literal value.
false
- A boolean literal value.
null
- A reference literal value.
Unused
const
- Although reserved as a keyword in Java,
const
is not used and has no function.[2][25] For defining constants in Java, see thefinal
keyword.
See also
References
- ^ https://docs.oracle.com/en/java/javase/15/docs/specs/sealed-classes-jls.html#jls-3.9
- ^ a b c "Java Language Specification - Section 3.9: Keywords". The Java Language Specification. Oracle. 2018-08-21. Retrieved 2018-12-25.
- ^ Goetz, Brian. "Warning about single underscore identifier". OpenJDK Lambda Development.
- ^ a b c "Java Language Keywords". The Java Tutorials. Sun Microsystems, Inc. Retrieved 2017-07-24.
- ^ a b c d e f "Primitive Data Types". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2008-12-03.
- ^ a b c d e f Flanagan 2005, p. 22.
- ^ a b c d e f g "Returning a Value from a Method". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2008-12-03.
- ^ a b c d e f g h i Flanagan 2005, pp. 66-67.
- ^ a b c "The switch Statement". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2014-12-18.
- ^ a b c Flanagan 2005, pp. 46-48.
- ^ a b "The while and do-while Statements". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2008-12-03.
- ^ a b Flanagan 2005, pp. 48-49.
- ^ a b "The if-then and if-then-else Statements". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2008-12-03.
- ^ a b Flanagan 2005, pp. 44-46.
- ^ a b "The for Statement". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2008-12-03.
- ^ Flanagan 2005, pp. 50-54.
- ^ https://docs.oracle.com/en/java/javase/15/docs/specs/sealed-classes-jls.html#jls. Missing or empty
|title=
(help) - ^ a b c "Controlling Access to Members of a Class". The Java Tutorials. Sun Microsystems, Inc. February 14, 2008. Retrieved 2008-12-03.
- ^ "Java Object Serialization Specification version 1.5.0". Sun/Oracle. 2004. 1.5 Defining Serializable Fields for a Class. Retrieved 2010-09-16. [permanent dead link]
- ^ Grosso, William (November 21, 2001). "Java RMI: Serialization". ONJava. O'Reilly Media. Declaring serialPersistentFields. Retrieved 2010-09-16.
- ^ "Java Volatile Keyword".
- ^ https://docs.oracle.com/en/java/javase/15/docs/specs/sealed-classes-jls.html#jls. Missing or empty
|title=
(help) - ^ https://docs.oracle.com/en/java/javase/15/docs/specs/sealed-classes-jls.html#jls. Missing or empty
|title=
(help) - ^ "Chapter 3. Lexical Structure". docs.oracle.com. Retrieved 2018-12-25.
- ^ a b Flanagan 2005, p. 20.
External links
- Gosling, James; Joy, Bill; Steele, Guy; Bracha, Gilad (June 2005). Java Language Specification (Third ed.). Addison-Wesley Professional. ISBN 978-0-321-24678-3. 만회하는 2008-12-03을 .
- Flanagan, David (2005 년 3 월). 요컨대 자바 (다섯 번째가 에드.). 한빛 . ISBN 978-0-596-00773-7. 만회하는 2010-03-03을 .