-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjava2
30 lines (23 loc) · 851 Bytes
/
java2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// datatypes in java
class Main{
public static void main(String args[])
{
// Creating and initializing custom character
char f = 'G';
// Integer data type is generally used for numeric values
int a = 89;
// use byte and short if memory is a constraint
byte b = 4;
// by default fraction value is double in java
double c = 7.453532;
// for float use 'f' as suffix as standard
float d = 6.733f;
// need to hold big range of numbers then we need this data type
long e = 92567;
System.out.println("char: " + f);
System.out.println("integer: " + a);
System.out.println("byte: " + b);
System.out.println("double: " + c);
System.out.println("float: " + d);
System.out.println("long: " + e);
}}