Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ByteShortInt {
- public static void main(String[]args) {
- //Integer has width of 32
- int myMinValue = -2_147_483_648;
- int myMaxValue= 2_147_483_647;
- int myTotal=(myMinValue/2);
- System.out.println("mytotal ="+myTotal);
- //byte has a width of 8
- byte myByteValue = -128;
- byte myNewByteValue=(byte)(myByteValue/2);
- System.out.println("myNewByteValue"+ myNewByteValue);
- //short has a width of 16
- short myshortValue = 32767;
- //long has width of 64
- long mylongValue=9_223_372_036_854_775_807L;
- //ASSINGMENT
- //1. create a byte variable and set it to any valid byte number
- byte myBytevalue2 =10;
- //2.create a short variable and set it to any valid short number
- short myShortvalue2=20;
- //3. create a int variable and set it to any valid int number
- int myIntvariable2=50;
- //4.create a variable of type long,and make it to equal to 5000+10 times the sum of the byte ,plus the short plus the int
- long myLongValue=50000 + 10 *(myBytevalue2+myShortvalue2+myIntvariable2);
- System.out.println("my value is " + myLongValue);
- }
- }
Add Comment
Please, Sign In to add comment