• Post Reply Bookmark Topic Watch Topic
  • New Topic

array values comparision  RSS feed

 
prakash moturu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

i have an array with 30 elements.i want to test first 10 values higest value and.then check the condition from 11 to 20 highest value.and again check the 20 to 30 higest value.

can any body give the idea.


bye
Prakash
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch prakash moturu ,

Yes you can sort the array descending and if this is a homework question then
DoYourOwnHomework.

And take some time to read the ask good questions link below.


Hope this helps
 
prakash moturu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i tried like this
public class check
{
int a[]={2,3,4,5,6,8,9,9,12,13,5,6,7,8,9,12};
int i,j;
void test()

{
for(i=0;i<a.length;i++)
{
for(j=i;j<=5;j++)
{
System.out.println("value:"+a[j]);

}

}
}
public static void main(String[] args)
{
check c=new check();
c.test();
}
}

i need after 5 elements from 9.
how to find.

by
praksh
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please indent your code and use UseCodeTags


What exactly are you trying to do in the above code?
Are you trying Bubble_sort.
 
prakash moturu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
thanks for your reply.

i want first five values and then next five values(starts from 6-11)like this

bye
prakash
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using <= in a for loop? That is a sure way to overrun the end of your array. More about for loops in this Java Tutorials section, and arrays here.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!