Left-shift operator (<<)
The << operator shifts an integer's bits left, filling the right side with zeros. The promoted left operand determines the result width and how the shift distance is masked.
CKTIS / Java
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The << operator shifts an integer's bits left, filling the right side with zeros. The promoted left operand determines the result width and how the shift distance is masked.
The <<= operator shifts bits left and stores the result in the same variable. If the variable has a primitive type, the result is implicitly converted back to that type.
The <= operator compares numeric values inclusively. It returns boolean; a comparison involving NaN returns false.
The < operator checks whether its left operand is strictly less than its right operand and returns boolean. Equal values produce false. Floating-point comparisons require care with NaN and signed zeros.
The && operator combines two conditions: the result is true only when both are true. When the left condition is false, the right condition is not evaluated.
The unary ! operator reverses a logical value: true becomes false, and false becomes true. It accepts boolean or Boolean and produces boolean. Applying it to a Boolean whose value is null throws NullPointerException.
The || operator combines conditions using logical OR. When the left operand is true, it skips the right operand; otherwise, it evaluates it.
The notation Type.FIELD / object.member distinguishes static field access through a type name from object field access. Field selection depends on the compile-time type, and instance field access requires a non-null reference.
The :: syntax adapts an existing method, constructor, or array creation operation to a functional interface. It does not invoke the referenced operation immediately; the target type determines compatible parameters and the result.
The * operator computes the product of two numeric values. Operand types determine the result type; integer overflow does not throw an exception.
The *= operator multiplies a variable's existing value by the right operand and stores the result back, converting it to the variable's type.
The % operator computes the remainder of integer or floating-point division. Its result is not necessarily nonnegative.
The %= operator calculates a remainder and stores it in the left operand, implicitly converting the result.
The >> operator shifts bits right while replicating the sign bit. Learn operand promotion, distance masking, and how it differs from >>> and division.
The >>= operator shifts bits right with sign extension and stores the result back in the same variable.
The binary - operator subtracts its right operand from its left operand. Learn numeric promotion, grouping, and integer overflow when subtracting values in Java SE 21.
The -= operator subtracts the right operand from a variable's value and stores the result in that same variable.
The `-x` operator computes arithmetic negation after numeric promotion. It does not change `x`. At the minimum `int` or `long` value, overflow leaves the value unchanged.
The expression +x returns the value of x after unary numeric promotion. It neither changes the sign nor increments x, but it can change the result type: byte, short, and char are promoted to int.
The >>> operator shifts bits right and fills vacated positions on the left with zeros. Learn how it differs from >>, how operands are promoted, and how shift distances are masked.
The >>>= operator shifts bits right, fills vacated positions with zeros, and stores the result in the same variable. Unlike >>=, it does not sign-extend; promotion and conversion back matter for narrow types.
System.out.println: practical reference: PrintStream.println writes the selected value using the matching overload, then writes the platform line separator; Object values are converted through String.valueOf.
In Java SE 21, an annotation declaration defines its data, where it may appear, and whether it is visible at run time. Learn how reflection reads that metadata, how repeated annotations are inherited, and how to scope unchecked-warning suppression.
An @interface declaration defines an annotation type: metadata attached to code. Elements describe the annotation's data, while meta-annotations control allowed locations, retention, repeatability, and inheritance.