In order to choose the data type we first need to find the type of data we want to store. After that we need to analyze the min & max value we might use.
- Literals
- 101 – Integer literal
- 10.1f – float literal
- 10.1 – double literal (default type for decimals)
- ‘A’ – character literal
- true – Boolean literal
- “Aryadeep” – String literal
- Keywords
Words that are reserved and used by the Java compiler. They cannot be used as an Identifier.
{You can visit docs.oracle.com for a comprehensive list}
Code as Described in the Video
package com.company;
public class CWH_04_literals {
public static void main(String[] args) {
byte age = 34;
int age2 = 56;
short age3 = 87;
long ageDino = 5666666666666L;
char ch = 'A';
float f1 = 5.6f;
double d1 = 4.66;
boolean a = true;
System.out.print(age);
String str = "Harry";
System.out.println(str);
}
}