Java - Programming Language
This course covers the basics of programming in Java. Work your way through the videos and we'll teach you everything you need to know to start your programming journey!

Data Types

Lesson 6
Author : Mike Dane
Last Updated : October, 2017


Code

CopyString name = "Mike";    // String's are objects not primitives
char testGrade = 'A';    // single 16-bit Unicode character.

byte age0 = 0;           // 8-bit signed two's complement integer
short age1 = 10;         // 16-bit signed two's complement integer.
int age2 = 20;           // 32-bit signed two's complement integer
long age3 = 30L;          // 64-bit optionally signed two's complement integer

float gpa0 = 2.5f;       // 32-bit floating point
double gpa1 = 3.5;       // double-precision 64-bit floating point

boolean isTall;          // 1 bit -> true/false
isTall = true;

name = "John";

System.out.println("Your name is " + name);
System.out.printf("Your name is %s \n", name);
/*
%f -> double or float
%d -> Integer
%s -> string
%c -> character
%b -> boolean
*/