Solution Review: Variable Declaration
The solution to the variable declaration exercise is explained in this lesson.
We'll cover the following...
Solution review
Let’s take a look at the code first:
Press + to interact
public class PrimitiveDataTypes {public static void main(String args[]) {byte age = 10;// byte distance = 144; // exceeding rangeshort height = 30000; // inside range// short elevation = 40000; // outside rangeint distanceBetweenTwoSatellites = 1000000000; // inside range// int distanceBetweenTwoGalaxy = 10000000000; // outside rangelong distanceBetweenTwoGalaxy = 10000000000L; // inside rangefloat rateOfInterest = 6/5f; // range is beyond the scope of discussiondouble rateOfHike = 456/123d; // range is beyond the scope of discussionchar capitalA = 'A';boolean isPossible = true;System.out.println("Age is: " + age);System.out.println("Height is: " + height);System.out.println("Distance between two satellites is: " + distanceBetweenTwoSatellites);System.out.println("Distance between two galaxies is: " + distanceBetweenTwoGalaxy);System.out.println("Rate of interest is: " + rateOfInterest);System.out.println("Rate of hike is: " + rateOfHike);System.out.println("CapitalA: " + capitalA);System.out.println("isPossible: " + isPossible);}}
Explanation
The solution is pretty straight forward. The highlighted lines (5, 7, ...