-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerics.java
More file actions
90 lines (81 loc) · 1.74 KB
/
Copy pathGenerics.java
File metadata and controls
90 lines (81 loc) · 1.74 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
import java.io.*;
import java.util.*;
class Harish
{
public static void main(String hh[])
{
//TO PERFORM INTEGER DATA TYPE
System.out.println("INTEGER DATATYPE::");
int m[]=new int[10];
int n;
Scanner d=new Scanner(System.in);
System.out.println("Enter the n value:");
n=d.nextInt();
System.out.println("Enter the Element one by one:");
for(int i=0;i<n;i++)
m[i]=d.nextInt();
Integer h[]=new Integer[n];
for(int i=0;i<n;i++)
h[i]=m[i];
Hari<Integer>ha=new Hari<Integer>(h);
ha.display();
//TO PERFORM FLOAT DATA TYPE
System.out.println("FLOAT DATATYPE::");
float s[]=new float[10];
int y;
//Scanner d=new Scanner(System.in);
System.out.println("Enter the n value:");
y=d.nextInt();
System.out.println("Enter the Element one by one:");
for(int i=0;i<y;i++)
s[i]=d.nextFloat();
Float p[]=new Float[y];
for(int i=0;i<y;i++)
p[i]=s[i];
joel<Float>hb=new joel<Float>(p);
hb.print();
//TO PERFORM ARRAYLIST CONCEPT
System.out.println("ARRAYLIST::");
int w;
ArrayList<Integer>x=new ArrayList<Integer>();
System.out.println("Enter the n value:");
w=d.nextInt();
System.out.println("Enter the element one by one:");
for(int i=0;i<w;i++)
x.add(d.nextInt());
Integer r[]=new Integer[w];
x.toArray(r);
joel<Integer>ob=new joel<Integer>(r);
ob.print();
}
}
class Hari<T>
{
T h[];
Hari(T h[])
{
this.h=h;
}
void display()
{
Arrays.sort(h);
for(int i=0;i<h.length;i++)
System.out.println(h[i]);
System.out.println("Maximum in Array:"+h[h.length-1]);
}
}
class joel<T1>
{
T1 h[];
joel(T1 h[])
{
this.h=h;
}
void print()
{
Arrays.sort(h);
for(int i=0;i<h.length;i++)
System.out.println(h[i]);
System.out.println("Maximum in Array:"+h[h.length-1]);
}
}