Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 5788

Java

case labels in switch

case labels in switch: A case label selects a switch branch by constant, enum value, String, or type pattern; Java 21 can also handle null explicitly.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

The catch clause

The catch clause: A catch clause handles an exception thrown from its associated try when the exception’s run-time type is assignable to the declared catch parameter type.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

class — class declaration

class — class declaration: The class keyword starts a class declaration, a named reference type with fields, methods, constructors, initializers, and member types.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

const — reserved unused keyword

const — reserved unused keyword: const is a reserved but unused Java keyword; it declares no constant and cannot be used as an identifier.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

continue — advance to the next iteration

continue — advance to the next iteration: continue ends the current iteration of a while, do, or for loop and transfers control to that loop’s continuation point.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

default — fallback branch or implementation

default — fallback branch or implementation: default marks an unmatched switch branch, an interface method with an implementation, or an annotation element’s default value.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

do — post-test loop

do — post-test loop: A do statement executes its body before testing the boolean expression after while, so the body runs at least once.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

else — alternative if branch

else — alternative if branch: else supplies the alternative statement for the nearest preceding if whose boolean condition evaluated to false.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

enum — enumeration type declaration

enum — enumeration type declaration: enum declares an enum class with a finite set of instances; each constant may take arguments and have a constant-specific class body that overrides behavior.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

exports — module package export

exports — module package export: An exports directive in module-info.java gives other modules access to a package’s public top-level types. Public or protected members and nested types remain subject to the ordinary access-control rules.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

extends — inheritance and upper bounds

extends — inheritance and upper bounds: extends names a class’s direct superclass, an interface’s direct superinterfaces, or the upper bound of a type parameter or wildcard.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

final — restriction on further change

final — restriction on further change: final restricts change: a variable can be assigned once, a method cannot be overridden, and a class cannot be subclassed.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

finally — cleanup after try

finally — cleanup after try: A finally clause belongs to try and runs after the try block and any selected catch when control completes them normally or by most abrupt-completion reasons.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

for — basic and enhanced loops

for — basic and enhanced loops: The for statement is either basic with initialization, condition, and update, or enhanced for, which successively assigns elements from an array or Iterable.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

goto — reserved unused keyword

goto — reserved unused keyword: goto is a reserved but unused Java keyword: the parser accepts it neither as an identifier nor as a jump statement.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

if — conditional selection

if — conditional selection: An if statement selects a branch from a boolean expression; an optional else belongs to the nearest unmatched if unless braces change the structure.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

implements — implementing interfaces

implements — implementing interfaces: An implements clause on a class or record declaration lists direct superinterfaces; a concrete class must provide inherited abstract methods.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

import — names from other packages

import — names from other packages: An import declaration in a compilation unit makes a type or static member available by simple name; it neither loads a class at runtime nor creates an alias.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

interface — type contracts

interface — type contracts: An interface declaration defines a reference type with member contracts; fields are public static final, while methods may be abstract, default, static, or private.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

module — JPMS module declaration

module — JPMS module declaration: module is a contextual keyword that begins a module declaration in module-info.java; outside that context it may be an ordinary identifier.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

native — method outside Java

native — method outside Java: The native modifier declares a method implemented outside the Java language; the declaration ends with a semicolon and has no Java body.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

new — creating objects and arrays

new — creating objects and arrays: The new operator creates a class instance through a class instance creation expression or creates an array; for a class it allocates the object and then runs the selected constructor.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

The keyword non-sealed

The keyword non-sealed: The non-sealed modifier reopens a class or interface that is a direct permitted subtype of a sealed type.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

The keyword open

The keyword open: The open modifier on a module declaration opens every package for deep run-time reflection without exporting those packages.

Basic · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime