Documente Academic
Documente Profesional
Documente Cultură
Integers:
- The data type capable of storing ONLY whole numbers.
- Has limitations, like not capable of storing numbers that
has decimals.
int ley=9;
int liah=5;
int lachi=1998;
System.out.println(ley);
System.out.println(liah);
System.out.println(lachi);
}
}
Character:
char ley='L';
char melca='i';
char lachi='a';
char alli='h';
System.out.println(ley);
System.out.println(melca);
System.out.println(lachi);
System.out.println(alli);
}
}
String:
String lachi="Goddess";
String melca="Ley";
float melca=5;
float lachi=10.56f;
System.out.println(melca);
System.out.println(lachi);
}
}
Double:
- The data type which can be used for storing numbers with
decimal values.
- double data type is a double-precision 64-bit IEEE 754 floating
point
- This data type is generally used as the default data type for
decimal values, generally the default choice
- Double data type should never be used for precise values such
as currency
double ley=98.2;
double lachi=97.60;
double liah=99.9;
long melca=330000;
long liah=9000000;
-Short data type can also be used to save memory as byte data type.
A short is 2 times smaller than an integer
-Default value is 0.
short lachi=30000;
}
Sample Scanner Program:
import java.util.Scanner;
String liah;
String ley;
System.out.println("Enter String:");
liah=lachi.next();
System.out.println("Enter String:");
ley=lachi.next();
}
}
Sample of Arithmetic Operations:
public class ArithmeticOperations{
public static void main(String[] args){
String liah="<3";
liah+="<3";
continue;
}
String alli="With her is Sanctuary";
System.out.println(alli);
double a=9;
double m=5;
double l=1997;
double al;
double aml;
double ac;
al=a*m;
aml=al*1997;
ac=aml/100;
System.out.println(ac +" " +"years is how long I want to
stay with her");
}
}