Labs
There is already a labs package in the project for this chapter.
- Write a program that declares and initializes two int variables:
big = 2147483647;bigger = big + 1;
For the big variable, use underscores in the literal value to make it easier to read. Print them both out and explain the results.
(Solution: Overflow.java)
- Write a program to see what variable types can do.
- Declare an int variable
validIntand assign it a valid value. - Declare a long variable
longIntand assignvalidIntto it. - Now try to assign
longIntback tovalidInt. Did it work?
(Solution: ValidInt.java)
- Try to draw the memory length diagram on Primitives and Memory. Erase it and try again.