Chapter 1- How to Choose Data Type for Our Variables







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
A constant value that can be assigned to the variable is called a literal.

  • 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);

}
}
Aryadeep

Welcome to CodeWithARYA. It's My Personal Reference Website. Where You Can Get Amazing Codes. Have a Look.

Post a Comment

Previous Post Next Post