-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArrayMethod2.java
34 lines (32 loc) · 982 Bytes
/
ArrayMethod2.java
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
/* Sort() method / Equals() method /copyOf() method */
import java.util.Scanner;
import java.util.Arrays;
class ArrayMethod2 {
public static void main(String[] args) {
int a[]=new int[5];
Scanner r=new Scanner(System.in);
System.out.print(" Enter data in array ");
for(int i=0;i<a.length;i++)
{
a[i]=r.nextInt();
}
int a2[]=Arrays.copyOf(a,5);
System.out.print(" Data of array2 ");
for(int i=0;i<a.length;i++)
{
System.out.print(a2[i] + " ");
}
/*Arrays.sort(a);
for(int i=0;i<a.length;i++)
{
System.out.print(a[i] + " ");
} */
/* System.out.print(" Enter data in array2 ");
for(int i=0;i<a2.length;i++)
{
a2[i]=r.nextInt();
}
boolean b=Arrays.equals(a,a2);
System.out.print(" Both Arrays are equal " +b); */
}
}