-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArraysInJava.java
More file actions
35 lines (29 loc) · 915 Bytes
/
ArraysInJava.java
File metadata and controls
35 lines (29 loc) · 915 Bytes
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
package arraysinjava;
import java.util.Scanner;
public class ArraysInJava {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int element;
System.out.println("Enter size of the array:");
int size=sc.nextInt();
int array1[]=new int[size];
System.out.println("Enter elements to the array:");
for(int i=0;i<size;i++){
element=sc.nextInt();
array1[i]=element;
}
for(int i : array1){
System.out.println("Element is:"+i);
}
array a=new array();
a.passArray(array1);
}
}
class array{
public void passArray(int[] array2){
System.out.println("Prinrting from the class.");
for(int i : array2){
System.out.println("Element is:"+i);
}
}
}