How Many Types To Reverse an Array in Java | String | Number - Java2021 : Online Tutorials Hub

Java2021 : Online Tutorials Hub

JAVA | Advance Java | MySQL | Data Structure | Git | HTML | CSS | JS

Latest

Post Top Ad

Tuesday, May 19, 2020

How Many Types To Reverse an Array in Java | String | Number

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 class ReverseArray {
    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 -


Important JAVA Programs for you -

More Topic for you -

No comments:

Pages