publicclass Constants { /* *Thiscompile-onlytestistomakesurethattheprimitive *publicstaticfinalfieldsinjava.lang.Floatare"constant *expressions"asdefinedby"TheJavaLanguageSpecification, *2ndedition"section15.28;adifferenttestchecksthevalues *ofthosefields.
*/ publicstaticvoid main(String[] args) throws Exception { int i = 0; switch (i) { case (int)Float.NaN: // 0
System.out.println("Float.NaN is a constant!"); break; case (int)Float.MIN_VALUE + 1: // 0 + 1
System.out.println("Float.MIN_VALUE is a constant!"); break; case (int)Float.MIN_NORMAL + 2: // 0 + 2
System.out.println("Float.MIN_NORMAL is a constant!"); break; caseFloat.MIN_EXPONENT: // -126
System.out.println("Float.MIN_EXPONENT is a constant!"); break; caseFloat.MAX_EXPONENT: // 127
System.out.println("Float.MAX_EXPONENT is a constant!"); break; case (int)Float.MAX_VALUE - 1: // Integer.MAX_VALUE - 1
System.out.println("Float.MAX_VALUE is a constant!"); break; case (int)Float.POSITIVE_INFINITY: // Integer.MAX_VALUE
System.out.println("Float.POSITIVE_INFINITY is a constant!"); break; case (int)Float.NEGATIVE_INFINITY: // Integer.MIN_VALUE
System.out.println("Float.NEGATIVE_INFINITY is a constant!"); break;
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.