my code should print numbers in reverse array
its not have error
but the lest for statement its not print array in reverse order

import java .util.Scanner;
public class R {

    public static void main (String [] args){
    	Scanner input=new Scanner(System.in);
    	int size;
    	System.out.println("Size ");
    	size=input.nextInt();
    	int [] array=new int [size];
    	System.out.println("enter element ");
    	for(int i=0;i<array.length;i++)
    		array[i]=input.nextInt();
    			System.out.println(" element of array is ");
    			for(int i=0;i<array.length;i++)
    		System.out.println(" "+array[i]);
int arrayb[]=new int[size];
 for(int i=0;i<array.length;i++)
			 {            arrayb[i] = array[i];        }
			 	System.out.println(" element of array befor reserved ");
			 	for(int i=0;i<arrayb.length;i++)
    		System.out.println(" "+arrayb[i]);
System.out.println(" element of array after reserved ");
for(int i=arrayb.length-1;i<=0;i--)
System.out.println(" "+arrayb[i]);
}}

the lest for statement its not print array in reverse order

Please post the program's output that shows the problem.

You need to edit your code and properly align the statements.
The messy way you have posted the code makes it very hard to read.

You should align the } vertically beneath the statement with the starting {
Do NOT put two }}s on the same line.
Do not put a statement on the same line following a {

Edited 4 Years Ago by NormR1: n/a

here i think is problem

for(int i=arrayb.length-1;i<=0;i--)
System.out.println(" "+arrayb[i]);

output

--------------------Configuration: <Default>--------------------
Size 
2
enter element 
1
2
 element of array is 
 1
 2
 element of array befor reserved 
 1
 2
 element of array after reserved 

Process completed.

Edited 4 Years Ago by programing: n/a

Copy the for loop's termination expression here and explain how you think it is working.

for(int i=arrayb.length-1;i<=0;i--)

loor start from the last elemnt to first element in array

This article has been dead for over six months. Start a new discussion instead.