Skip to content

Commit afa5406

Browse files
committed
passing arrays as argument to Methods
1 parent f9c7c73 commit afa5406

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/passElements.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
/*This Program demonstrates passing individual array elements as arguments
3+
* to a method*/
4+
public class passElements {
5+
public static void showValue(int n){
6+
System.out.println(n+" ");
7+
}
8+
9+
public static void main(String[] args) {
10+
int [] numbers={5,10,15,15,30};
11+
for (int i = 0; i < numbers.length; i++) {
12+
showValue(numbers[i]);
13+
14+
}
15+
}
16+
17+
18+
}

0 commit comments

Comments
 (0)