Click here to Skip to main content
15,917,702 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello this is a part of a sparsematrix , I have a questions with the printing of things before and after a while loop , the code basically at the begining has
" System.out.print("column number " + " test abcd "); " which can get printed if you compile however after the while loop has been finished then why does the second print out statement not work which is
System.out.print("column number " + colNumber + " test efgh "); ,
this is almost all the way down the bottom .
This print statement after the while loop does not get printed out .
This is basically the problem I am having .

Can anybody tell me what the problem is ?

Thank you

------------------------------



Here is the code :


public void print(int number)
   {
                  System.out.print("column number " + "  test abcd ");

               int countr = 0;
               int cntr = 0;

       number = 0;
       while( number == number )
       {
                if(!see_column(number))
                {
                  return;
               }

            Node columnitr = enter;
            while(columnitr.getcolmn() != number)
                {
                columnitr = columnitr.getright();
                }

            Node rowitr = columnitr;
            while(rowitr.getdown() != columnitr)
               {

                rowitr = rowitr.getdown();
             System.out.print("   ("+rowitr.getrow()+"  , "
                      +rowitr.getcolmn()+  "  )  :  "
                            +rowitr.getvalue());
                }

              number++;
              countr = rowitr.getcolmn();

              cntr = countr + 1;
              if (cntr > countr)
              {
              System.out.println("number of columns : "  +  cntr);
              System.out.print("column number " + colNumber + " -- ");
            }
       }


     System.out.print("column number " + colNumber + "  test efgh ");



   }
Posted
Updated 27-Jan-15 15:49pm
v3
Comments
Sergey Alexandrovich Kryukov 27-Jan-15 20:27pm    
Just use the debugger...
—SA

1 solution

C#
" System.out.print("column number " + " test abcd "); " which can get printed if you compile however after the while loop has been finished then why does the second print out statement not work which is
System.out.print("column number " + colNumber + " test efgh "); ,


Are you sure the the while loop has been finished running?

In your looping condition, you put:

C#
while( number == number )


Ares those numbers are same things or different? If they are the same, is there any way so that those two numbers will different while the loop continues? If not, how the loop will break?

Though I am asking all the questions instead of answering, I think you can find the answer by yourself.

- DP
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900