< prev index next > src/java.base/share/classes/java/lang/Float.java
Print this page
import java.util.Optional;
import jdk.internal.math.FloatConsts;
import jdk.internal.math.FloatingDecimal;
import jdk.internal.math.FloatToDecimal;
+ import jdk.internal.value.DeserializeConstructor;
import jdk.internal.vm.annotation.IntrinsicCandidate;
/**
* The {@code Float} class is the {@linkplain
* java.lang##wrapperClass wrapper class} for values of the primitive
* {@code String} to a {@code float}, as well as other
* constants and methods useful when dealing with a
* {@code float}.
*
* <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
! * class; programmers should treat instances that are
! * {@linkplain #equals(Object) equal} as interchangeable and should not
! * use instances for synchronization, or unpredictable behavior may
! * occur. For example, in a future release, synchronization may fail.
*
* <h2><a id=equivalenceRelation>Floating-point Equality, Equivalence,
* and Comparison</a></h2>
*
* The class {@code java.lang.Double} has a {@linkplain
* {@code String} to a {@code float}, as well as other
* constants and methods useful when dealing with a
* {@code float}.
*
* <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
! * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
! * as interchangeable and should not use instances for synchronization, mutexes, or
! * with {@linkplain java.lang.ref.Reference object references}.
! *
+ * <div class="preview-block">
+ * <div class="preview-comment">
+ * When preview features are enabled, {@code Float} is a {@linkplain Class#isValue value class}.
+ * Use of value class instances for synchronization, mutexes, or with
+ * {@linkplain java.lang.ref.Reference object references} result in
+ * {@link IdentityException}.
+ * </div>
+ * </div>
*
* <h2><a id=equivalenceRelation>Floating-point Equality, Equivalence,
* and Comparison</a></h2>
*
* The class {@code java.lang.Double} has a {@linkplain
* @author Lee Boynton
* @author Arthur van Hoff
* @author Joseph D. Darcy
* @since 1.0
*/
+ @jdk.internal.MigratedValueClass
@jdk.internal.ValueBased
public final class Float extends Number
implements Comparable<Float>, Constable, ConstantDesc {
/**
* A constant holding the positive infinity of type
* @param f a float value.
* @return a {@code Float} instance representing {@code f}.
* @since 1.5
*/
@IntrinsicCandidate
+ @DeserializeConstructor
public static Float valueOf(float f) {
return new Float(f);
}
/**
< prev index next >