TableSwitchInstruction (Java SE 23 & JDK 23)
Description: declaration: module: java.base, package: java.lang.classfile.instruction, interface: TableSwitchInstruction
Keywords: java.lang.classfile.instruction.TableSwitchInstruction interface

# Interface TableSwitchInstruction

All Superinterfaces:
  `ClassFileElementPREVIEW`, `CodeElementPREVIEW`, `InstructionPREVIEW`

public sealed interface TableSwitchInstruction extends InstructionPREVIEW
`TableSwitchInstruction` is a preview API of the Java platform.
Programs can only use `TableSwitchInstruction` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a `tableswitch` instruction in the `code` array of a `Code` attribute. Delivered as a `CodeElement`PREVIEW when traversing the elements of a `CodeModel`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<SwitchCasePREVIEW>`
  `cases()`
  Returns the cases of the switch.
  `LabelPREVIEW`
  `defaultTarget()`
  Returns the default target of the switch.
  `int`
  `highValue()`
  Returns the high value of the switch target range, inclusive.
  `int`
  `lowValue()`
  Returns the low value of the switch target range, inclusive.
  `static TableSwitchInstructionPREVIEW`
  `of(int lowValue, int highValue, LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases)`
  Returns a table switch instruction.

  ### Methods declared in interface java.lang.classfile.InstructionPREVIEW

  `opcode, sizeInBytes`

- ## Method Details

  - ### lowValue

    int lowValue()
    Returns the low value of the switch target range, inclusive.
    Returns:
      the low value of the switch target range, inclusive

  - ### highValue

    int highValue()
    Returns the high value of the switch target range, inclusive.
    Returns:
      the high value of the switch target range, inclusive

  - ### defaultTarget

    LabelPREVIEW defaultTarget()
    Returns the default target of the switch.
    Returns:
      the default target of the switch

  - ### cases

    List<SwitchCasePREVIEW> cases()
    Returns the cases of the switch.
    Returns:
      the cases of the switch

  - ### of

    static TableSwitchInstructionPREVIEW of(int lowValue, int highValue, LabelPREVIEW defaultTarget, List<SwitchCasePREVIEW> cases)
    Returns a table switch instruction.
    Parameters:
      `lowValue` - the low value of the switch target range, inclusive
      `highValue` - the high value of the switch target range, inclusive
      `defaultTarget` - the default target of the switch
      `cases` - the cases of the switch
    Returns:
      a table switch instruction