public class Foreach {
public static void main(String[] args) {
// TODO Auto-generated method stub
int k;
int array[] = {1,2,3,4,5};
for(int j:array){
//for(int i=0;i<=4;i++){
System.out.println();
System.out.println("The value of elements in the array before adding + is" +j);
k=j+1;
System.out.println("The value of elements in the array after adding + is" +k);
//}
//System.out.println("The value of the j is " +j);
}
}
}
Output:-
The value of elements in the array before adding + is1
The value of elements in the array after adding + is2
The value of elements in the array before adding + is2
The value of elements in the array after adding + is3
The value of elements in the array before adding + is3
The value of elements in the array after adding + is4
The value of elements in the array before adding + is4
The value of elements in the array after adding + is5
The value of elements in the array before adding + is5
The value of elements in the array after adding + is6
No comments:
Post a Comment