Primitives
Using Primitives and Wrappers
int x = 3;
System.out.println(x);
//For a whole number use an Integer
double y = 2.3;
System.out.println(y);
//To use decimal points use a double
String w = "Hello";
String m = "World";
System.out.println(w + m);
//For letters/sentences use strings
boolean ellieHasADog = true;
boolean ellieHasAFish= false;
if (ellieHasADog)
{
System.out.println("Ellie has a dog!");
}
else if (ellieHasAFish)
{
System.out.println("Ellie has a fish?");
}
Integer lucky = 444;
String luckyStr = lucky.toString();
System.out.println("luckyStr: " + luckyStr);
System.out.println("length is:"+luckyStr.length());
double firstNumber = 5 / 2.0;
System.out.println("The first number is-" + firstNumber);
int firstNumberRounded = (int)(firstNumber + 0.5);
System.out.println("The first number rounded is-" + firstNumberRounded);