I have stuck with one problem.
I have created my own program that will work.
In program there are two for loop.
Now my problem is

for(int i=0;i<q;i++)
{
    for(int r=0;r<q;r++)
    {
        /*perform some kind of operations
        returns one integer value.*/

        /*here q=4 so first time r loop execute 4 times
        but, when it completes for i=0,it will return one no.
        when i=1,it again goes to r loop, but it will skip r loop,of the no. returned by it previously.
        when i=2,there will be again one no. returned by it, this time it will skip two r loop.
        and same as it is upto end.*/
     }
     int number=no. to skip;
  }

please help me how can i design such logic.

ehm ... what do you mean, your for loop will "return an int value"?

You can use it to print the elements of an array in ascending or descending order. Maintain a boolean list of size q to mark off the position of the largest (or smallest) element obtained from the inner loop, ignore it in the next turn if the position is marked.

please help me how can i design such logic.

Well, we're kinda confused about your explanation too. So, if you'll try to explain better what you're trying to accomplish inside that 2 for loops, we'll might help you, starting with these:

int number=no. to skip;

and

but it will skip r loop,of the no. returned by it previously.

parts.

my code is as followed:
please tell how can i skip the inner loop with variable ski[ano].

for(int r = 0;r<q;r++)
            {
                Set s = temp.keySet();
                Iterator it1 = s.iterator();
                int map_size = s.size();
                System.out.println("\n"+s);
                StringBuilder sb = null;
                int rep=0;

                for(int p=0;p<q;p++)
                {  
                if(ski[p]==1)
                {
                    //break;
                    //continue;
                }
                else
                {

                while(it1.hasNext())
                {

                    String[] a1 = temp.get((Integer)it1.next());
                    System.out.println("\n /////////////////////////////////////////////////////////////////////////");

                    if(len[r]>2)
                    {
                        if(a1[loc[r]].length()==1)
                        {
                            sb = new StringBuilder(a1[loc[r]]);

                            sb.setCharAt(0,'*');
                            a1[loc[r]]=sb.toString();
                        }
                        else
                        {
                            sb = new StringBuilder(a1[loc[r]]);
                            rep = a1[loc[r]].length()-1;
                            sb.setCharAt(rep,'*');
                            a1[loc[r]]=sb.toString();
                        }
                    }
                    if(len[r]<=2)
                    {
                        int x = Integer.parseInt(a1[loc[r]]);
                        if(x>=0 && x<5){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[0-5]");}
                        if (x >= 5 && x < 10) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[5-10]");}
                        if (x >= 10 && x < 15) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[10-15]");}
                        if(x >= 15 && x < 20) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[15-20]");}
                        if(x >= 20 && x < 25) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[20-25]");}
                        if(x >= 25 && x < 30) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[25-30]");}
                        if(x >= 30 && x < 35) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[30-35]");}
                        if(x>=35 && x<40){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[35-40]");}
                        if(x>=40 && x<45){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[40-45]");}
                        if(x>=45 && x<50){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[45-50]");}
                        if(x>=50 && x<55){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[50-55]");}
                        if(x>=55 && x<60){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[55-60]");}
                        if(x>=60 && x<65){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[60-65]");}
                        if(x>=65 && x<70){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[65-70]");}
                        if(x>=70 && x<75){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[70-75]");}
                        if(x>=75 && x<80){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[75-80]");}
                        if(x>=80 && x<85){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[80-85]");}
                        if(x>=85 && x<90){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[85-90]");}
                        if(x>=90 && x<95){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[90-95]");}
                        if(x>=95 && x<100){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[95-100]");}
                    }

                    for(int as=0;as<a1.length;as++)
                    {
                        System.out.print(a1[as]+"   \t");
                    }

                }
              }
                }
                ja[r]=test(a,asMap,q,loc,k,temp);

                System.out.println("\nfor loop Value of temp11="+temp11+" and value of an = "+ano);
                ano=ano_gain(r,ja,loc,map_size,q,ano,anon_gain);

                System.out.println("\nvalue to ano q.i = "+loc[ano]+" location is = "+ano);

                replace(temp2,temp);
                      ski[ano]=1;
                vis(a,ano,temp,q,len,loc,k); // i want to call this method after every p loop is completed.
            }

here temp,temp2,and asMap are Hashmap.
q=4
k=3
ja[r] = no.of rows having same value
loc = location of particular column
a=size of original map

i want to skip the loop of p when it match with ski[].

Simply declare number outside the 2 for-loops and may initiate a value that will never expect to be seen from the return inside the inner loop (a negative number maybe?). Also, declare another variable and may name it numberToSkip outside the 2 loops too. Inside the first loop layer right before you call the inner loop, assign the value of number to numberToSkip. Then inside the inner most loop, check if the value of r is equal to numberToSkip. If it is, use continue; keyword to skip it. The location wherever you compute for number is fine, but do not redeclare the variable again. Below is a sample code taken from your original post.

int number=-1;    // skipping number
int numberToSkip; // place holder for the number used in skipping
for(int i=0;i<q;i++) {
  numberToSkip = number;  // check for previous skipping number assigned
  for(int r=0;r<q;r++) {
    if (r==numberToSkip) { continue; }  // skip the number
    ...
  }
  number=no. to skip;    // recalculate the skipping number
}

// You could also do it this way inside the loop...
for(int i=0;i<q;i++) {
  numberToSkip = number;  // check for previous skipping number assigned
  for(int r=0;r<q;r++) {
    if (r!=numberToSkip) {  // will work on it if not the skipping number
      ...
    }
  }
  number=no. to skip;    // recalculate the skipping number
}

dear Taywin:
I appreciate your suggestion.I get it what you want to give suggestion.

But the problem is:
it always skip only one loop that stored in numberToSkip.
but i want, when outer loop runs 2nd time it skips one times that is no. stored in previous loop.
when outer loop runs 3rd time it skips two times,that no. returned in previous both loops.

So i want like this.
if q=4.
so in first loop i=0 and r executes 4 times.(nothing will skip,return one no.)
2nd loop i=1 and r executes 3 times.(skips 1 time,by no. returned by previous loop)
3rd loop i=2 and r executes 2 times.(skips 2 time,by no. returned by previous 2 loop)
4th loop i=3 and r executes 1 times.(skips 3 time,by no. returned by previous 3 loop)

please help me what to do.For making or to get above output.

Thanks

It's really hard to understand your requirement, but is this what you mean (pseudocode)?...

  valuesToSkip = new ArrayList<Integer>

  for (r ...
     if (valuesToSkip.contains(r)) continue;
     ...
     valuesToSkip.add(anotherValueThatYouWantToSkipNextTime)
commented: good suggestion +3

I believe you got it, James. He needs to add the new number into the ArrayList, and then skip it if the loop number is contained by the check.

Thanks james and Taywin.

It seems to be good way.
Just let me try it out..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.