Compile-time calculation: Difference between revisions

m
Code corrupted by "Bad Gateway" error during uploading process.
m (Added language identifier.)
m (Code corrupted by "Bad Gateway" error during uploading process.)
Line 836:
 
Note: Currently, the mediawiki implementation is corrupting the above display due to a cascading sequence of bad design decisions and mis-interpreted specifications on the part of someone "contributing" to that implementation. To work around this issue, and see the original display, you can currently use either the "Edit" or "View Source" option, depending on whether you are logged in to rosettacode with an account that has edit rights here. (Please don't actually save changes though.) If you are using View Source, you might want to do that in a new tab (so you also stay here with this view) and use your browser's search capability to quickly scroll to this location in the source view.
 
=={{header|Java}}==
Compile time calculation of constant values is possible in Java.
<syntaxhighlight lang="">
 
import java.util.List;
import java.util.stream.IntStream;
 
public final class CompileTimeCalculation {
 
public static void main(String[] aArgs) {
System.out.println(tenFactorial);
System.out.println(word);
System.out.println(numbers);
}
private static int tenFactorial = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1;
private static String word = "Street".substring(1, 5);
private static List<Integer> numbers = IntStream.rangeClosed(1, 10).boxed().toList();
 
}
</syntaxhighlight>
{{ out }}
<pre>
3628800
tree
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
</pre>
 
=={{header|Java}}==
908

edits