Array in Reverse order
public class Array_Reverse
{
public static void main(String[] args)
{
int aArray[]= new int[2];// 2 means not 2+1 --> aArray[0] , aArray[1]
for (int iSize=0 ; iSize<=aArray.length-1 ; iSize++)
{
aArray[iSize]=Integer.parseInt(JOptionPane.showInputDialog("Enter value for aArray["+iSize+"]" ));
}
//System.out.println(aArray[0]);
int iSize=aArray.length-1;
for ( iSize=aArray.length-1 ; iSize>=0 ; iSize--) //"iSize>=0 "Execute if true till false
{
System.out.println("aArray["+iSize+"]="+aArray[iSize]);
}
for ( iSize=0 ; iSize<=aArray.length-1 ;iSize++ )// Execute if true till false
{
System.out.println(aArray[iSize]);
}
System.out.println("Done");
{
int aArray[]= new int[2];// 2 means not 2+1 --> aArray[0] , aArray[1]
for (int iSize=0 ; iSize<=aArray.length-1 ; iSize++)
{
aArray[iSize]=Integer.parseInt(JOptionPane.showInputDialog("Enter value for aArray["+iSize+"]" ));
}
//System.out.println(aArray[0]);
int iSize=aArray.length-1;
for ( iSize=aArray.length-1 ; iSize>=0 ; iSize--) //"iSize>=0 "Execute if true till false
{
System.out.println("aArray["+iSize+"]="+aArray[iSize]);
}
for ( iSize=0 ; iSize<=aArray.length-1 ;iSize++ )// Execute if true till false
{
System.out.println(aArray[iSize]);
}
System.out.println("Done");
}
}
}
No comments:
Post a Comment