Variables & Data Types

Primitive types, reference types, declaration, literals.


Java has eight primitive data types: byte, short, int, long, float, double, char, boolean. Reference types include classes, interfaces, arrays and enums. Variables are strongly typed; you must declare the type.

Example
int age = 25;
double price = 99.99;
boolean isJava = true;
String name = "Super";
Video Lesson Open in new tab
Quiz
1. Which of the following is NOT a primitive data type in Java?
Coding Problems
1. Write a program that converts a temperature from Celsius to Fahrenheit (F = C*9/5 + 32).
Discussion

Login to join the discussion.


No comments yet.