06-20-2011, 10:46 PM
Yeah I have a Java programming online course, I've been doing decent but now we're at Arrays and I'm starting to get confused.
Anyway I need help figuring out the value of the num array with this program. I think I have an idea but I'm not sure. Take a look.
public class QuestionTwo
{
public static void main(String args [])
{
int [] num= {20,50,10,70,40,80,30,90,60};
int t=0;
for (int i=0; i<num.length; i++)
{
for (int j=i+1; j<num.length; j++)
if (num[i]>num[j])
{
t=num[i];
num[i]=num[j];
num[j]=t;
}
}
}
}
Anyway I need help figuring out the value of the num array with this program. I think I have an idea but I'm not sure. Take a look.
public class QuestionTwo
{
public static void main(String args [])
{
int [] num= {20,50,10,70,40,80,30,90,60};
int t=0;
for (int i=0; i<num.length; i++)
{
for (int j=i+1; j<num.length; j++)
if (num[i]>num[j])
{
t=num[i];
num[i]=num[j];
num[j]=t;
}
}
}
}