-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticArray.java
More file actions
128 lines (107 loc) · 3.41 KB
/
Copy pathStaticArray.java
File metadata and controls
128 lines (107 loc) · 3.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
public class StaticArray {
public static void main(String args[]){
//CREATING AND PRINTING STATIC ARRAY
//PRIMITIVE DATATYPES
byte b[]= {3,2,4,1,6};
for(int i=0; i<b.length; i++){
System.out.print(b[i] + " ");
}
System.out.println();
short s[]= {12, 32, 15, 27, 29};
for(int i=0; i<s.length; i++){
System.out.print(s[i] + " ");
}
System.out.println();
int i1[]= {37, 45, 51, 33, 40};
for(int i=0; i<i1.length; i++){
System.out.print(i1[i] + " ");
}
System.out.println();
long l[]= {89, 78, 91, 64, 83};
for(int i=0; i<l.length; i++){
System.out.print(l[i] + " ");
}
System.out.println();
float f[]= {1.2f, 5.6f, 3.1f, 4.6f, 8.9f};
for(int i=0; i<f.length; i++){
System.out.print(f[i] + " ");
}
System.out.println();
double d[]= {21.3, 45.2, 54.6, 70.5, 29.3};
for(int i=0; i<d.length; i++){
System.out.print(d[i] + " ");
}
System.out.println();
char ch[]= {'a', 40, '&', 'Q', '#'};
for(int i=0; i<ch.length; i++){
System.out.print(ch[i] + " ");
}
System.out.println();
boolean bool[]= {true, false, false, true, false};
for(int i=0; i<bool.length; i++){
System.out.print(bool[i] + " ");
}
System.out.println();
System.out.println();
//WRAPPER CLASSES
String str[] = {"Java", "C", "Python", "C++"};
for(int i=0; i<str.length; i++){
System.out.print(str[i] + " ");
}
System.out.println();
Byte by[] = {3,2,4,1,6};
for(byte by1: by){
System.out.print(by1 + " ");
}
System.out.println();
Short sh[]= {12, 32, 15, 27, 29};
for(int i=0; i<sh.length; i++){
System.out.print(sh[i] + " ");
}
System.out.println();
Integer in[]= {37, 45, 51, 33, 40};
for(int in1: in){
System.out.print(in1 + " ");
}
System.out.println();
Long lo[]= {89L, 78L, 91L, 64L, 83L};
for(int i=0; i<lo.length; i++){
System.out.print(lo[i] + " ");
}
System.out.println();
Float fl[]= {1.2f, 5.6f, 3.1f, 4.6f, 8.9f};
for(float fl1: fl){
System.out.print(fl1 + " ");
}
System.out.println();
Double db[]= {21.3, 45.2, 54.6, 70.5, 29.3};
for(int i=0; i<db.length; i++){
System.out.print(db[i] + " ");
}
System.out.println();
Character cha[]= {'a', 40, '&', 'Q', '#'};
for(char cha1: cha){
System.out.print(cha1 + " ");
}
System.out.println();
Boolean bl[]= {true, false, false, true, false};
for(int i=0; i<bl.length; i++){
System.out.print(bl[i] + " ");
}
System.out.println();
System.out.println();
//STORING HETEROGENEOUS DATA
var a= new Object[]{
45, "Hello", '$', 8.5f
};
for(int i=0; i<a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
Object o[] = { 8.6f, "Java", 90 , 'c'};
for(int i=0; i<o.length; i++){
System.out.print(o[i] + " ");
}
System.out.println();
}
}