Loop program

package com.vaannila.student;

public class MyLoop{
      public static void main(String argv[]){
      MyLoop ml = new MyLoop();
      ml.amethod();
      }

       public void amethod(){
                for(int K=0;K<5l;K++){
                     System.out.println("Outer "+K);
                     for(int L=0;L<5;L++)
                     {System.out.println("Inner "+L);}
                   }
          }
}

I was trying above example from link
http://www.jchq.net/certkey/0202certkey.htm
got output like



Outer 0
Inner 0
Inner 1
Inner 2
Inner 3
Inner 4
Outer 1
Inner 0
Inner 1
Inner 2
Inner 3
Inner 4
Outer 2
Inner 0
Inner 1
Inner 2
Inner 3
Inner 4
Outer 3
Inner 0
Inner 1
Inner 2
Inner 3
Inner 4
Outer 4
Inner 0
Inner 1
Inner 2
Inner 3
Inner 4


I was trying to understand the output.Why outer loop did not execute until 50 times( ask<51). Please advise. Any links, ideas, resources,sample code highly appreciated. thanks in advance.
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

for_yanCommented:
That is not digit "1" but letter "l" which yu hvae in "51"  
0
for_yanCommented:

change this line:
  for(int K=0;K<5l;K++){

to this line:

  for(int K=0;K<51;K++){

It thinks that 5l is (long)5  and therefore compiler does not catch it

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
for_yanCommented:
By the way if you want it to execute 50 times you should have it

K<50 (not K<51) as it starts with 0

 
0
gudii9Author Commented:
>>>That is not digit "1" but letter "l"

what is use of that character in this for loop. please advise
0
rrzCommented:
>what is use of that character in this for loop.  
The  l   tells the compiler to make that number a long primitive type. But it is not really useful to do so. It makes no difference in this case.   It make be a typing mistake here.
http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.