Gudam,
Please help me, regarding my ascending code.I've been doubt how to compare the two loop
which is the outer loop and inner loop.I cant get the the output which is ascending in
form...Please guide me this time because I'm just a beginner. Thank you in advance
Here is my code...
import java.util.*;
public class Array
{
private Scanner scan;
private int num [];
public Array()
{
scan=new Scanner(System.in);
num =new int [5];
}
public void fillArray()
{
for(int i=0; i<num.length; i++)
{
System.out.print("Enter an integer: ");
num[i]=scan.nextInt();
}
}
public void Ascending()
{
System.out.print("Ascending: ");
for(int i=0; i<num.length-1; i++)
{
for(int j=0; j<num.length-1; j++)
{
if(num[i]>num[j+1])
int temp[0];
{
temp=num[j];
num[i]=num[j+1];
num[j+1]=temp;
}
}
}
for(int a=0; a<num.length; a++)
System.out.print(num[a]+ " ");
}
public static void main(String[] args)
{
Array a=new Array();
a.fillArray();
System.out.print("");
a.Descending();
}