Combining the two integer's into a long.
Code:
int a = 12345;
int b = 54321;
long total = (a << 32) + b; //shifting the 32 bits from value 'a' right 32 bits so we can store 'b' in the original slot 'a' was in
To get the value of 'b'
Code:
int value = (int) total; //no need for shift as Integer has 32 bits and will take ending 32 bits of a 64 bit Long
To get the value of 'a'
Code:
int value = (int) (total >> 32); //shifting the bits right 32 discarding the value 'b' (in slot 0-31) and replacing them with value 'a' (in slot 32-64)
Code:
0 (value of a bit) [1 bit]
00000000 (value of a byte) [8 bits]
0000000000000000 (value of a short) [16 bits]
00000000000000000000000000000000 (value of an integer) [32 bits]
0000000000000000000000000000000000000000000000000000000000000000 (value of a long) [64 bits]
This isn't limited to Integer's into longs, you can/could store 4 bytes into an integer if you really wanted to.
Edit: Hope this helps, and whoop whoop x50 posts!