Reverse an Array ( Number Array)
public class ReverseArray {
public static void main(String[] args) {
int array[]={1,2,3,4,5,6};
for (int i=5;i>=0;i--){
System.out.print(array[i]);
}
}
}
Output : 6,5,4,3,2,1
Reverse an Array ( String Array)
public static void main(String[] args) {
String array[]={"ravi","rahul","ajay","lalu"};
for (int i=3;i>=0;i--){
System.out.print(array[i]+" ");
}
}
}
Output :
lalu ajay rahul ravi
click to next -
- Merge Array in Java
- Sort Array
- Insert Element in Array
- Missing Element in Array
- 4 ways to print Array in Java
- 2-D Array in Java
- Anonymous Array in Java
- Single Dimensional Array in Java
- Find Second Largest Number in Array
- Delete an Element in Array in Java
Important JAVA Programs for you -
More Topic for you -
No comments:
Post a Comment