-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic_Variables.java
More file actions
110 lines (80 loc) · 2.41 KB
/
Basic_Variables.java
File metadata and controls
110 lines (80 loc) · 2.41 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package basics;
public class Basic_Variables {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*syntax:
type variable = value;
*/
//1
String name;
name="John";
System.out.println("1->"+name);
//2
int mynum=15;
System.out.println("2-> "+mynum);
//3
int Mynum=15;
Mynum=20;
System.out.println("3-> "+Mynum);
//4
float num=0.99f;
System.out.println("4-> "+num);
//5
char letter='d';
System.out.println("5-> "+letter);
//6
boolean val=true;
System.out.println("6-> "+val);
//7
String fName="Jhon";
String lName="Doe";
String fullName=fName+lName;
System.out.println("7-> "+fullName);
//8
int x=5;
int y=7;
System.out.println("8th output");
System.out.println(x+y);
System.out.println("8-> "+x+y);
//9
int a=5,b=8,c=3;
System.out.println("9th output");
System.out.println(a+b+c);
System.out.println("9-> "+a+b+c);
//data types
//primitive data types
System.out.println("________________________________________________________");
System.out.println("Data Types:");
System.out.println("for whole numbers: byte,short,int,long: ");
byte Num=100;
System.out.println(Num);
short num1=5000;
System.out.println(num1);
int num2=10000;
System.out.println(num2);
long num3=100000000000000L;
System.out.println(num3);
System.out.println("________________________________________________________");
System.out.println("for floating point number:");
float fnum=0.99F;
System.out.println(fnum);
double dnum=19.99d;
System.out.println(dnum);
System.out.println("________________________________________________________");
System.out.println("For Scientific numbers: ");
float f1 = 35e3f;
double d1 = 12E4d;
System.out.println(f1);
System.out.println(d1);
System.out.println("________________________________________________________");
System.out.println("boolean values: ");
boolean isJavaFun=true;
boolean isFishTasty=false;
System.out.println(isJavaFun);
System.out.println(isFishTasty);
System.out.println("________________________________________________________");
System.out.println("Non primitive data types: String,Class,Array,Interface etc ");
String name1="Sunil";
System.out.println(name1);
}
}