This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Integer x = 127; | |
System.out.println(x); // 1 | |
System.out.println(127); // 2 | |
System.out.println((Integer) 127); // 3 | |
System.out.println(new Integer(127)); // 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static { | |
// high value may be configured by property | |
int h = 127; | |
String integerCacheHighPropValue = | |
sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high"); | |
if (integerCacheHighPropValue != null) { | |
int i = parseInt(integerCacheHighPropValue); | |
i = Math.max(i, 127); | |
// Maximum array size is Integer.MAX_VALUE | |
h = Math.min(i, Integer.MAX_VALUE - (-low) -1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ForkJoinPool; | |
import java.util.concurrent.RecursiveTask; | |
/** | |
* @author Ivan Babanin ([email protected]) | |
*/ | |
public class TestFJP { | |
public static void main(String[] args) throws InterruptedException { | |
ForkJoinPool forkJoinPool = new ForkJoinPool(1); | |
forkJoinPool.submit(new Task(0)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.ByteBuffer; | |
/** | |
* @author Ivan Babanin ([email protected]) | |
*/ | |
public class StoreFloatsInDouble { | |
public static void main(String[] args) { | |
double pack = pack(1.1f, 1.2f); | |
float[] unpack = unpack(pack); | |
System.out.println(unpack[0] + "\n" + unpack[1]); |
NewerOlder