Looping in java

Looping in java

Before we know about loop first to fall we need to understand which type of problem we will phase

If  we can imagine programming without loop.

Example: if we can say wap for print 1 to 100. And we don’t know about loops.

 

So what is our approach :

Looping In Java

  1. System.out.print(“1 2 3 4 5……99 100”);
  2. And if we need output like this

1

2

3

99

100;

Then we will write System.out.println(“1”); System.out.println(“2”); System.out.println(“3”);

System.out.println(“99”); System.out.println(“100”);

So we can see if we don’t know about loop so our life in programming its so difficult whenever

We need to iteration in programme plus our time and efficiency of a programme both will effect.

So if you want overcome from this problem then one person is here for our help and that person

Name is loop.

What is loop: Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true. Java provides Four ways for executing the loops.

Following are- 

  1. While Loop
  2. Do While Loop
  3. For Loop
  4. For Each Loop

So now above  programme will make very easily with loops and complete with some statements.

Now next question is why java provide for way of looping?

Ans: all are use for looping purpose in java but way of working is totally different like

If i will say WAP for add two numbers

Then there is a different way to write this programme but output will be same.

First Way : int c=a+b;

System.out.println(“result of c is :”+c);

Second Way :   System.out.println(“output is this:”+a+b);

Third Way : System.out.println(“result is::”+10+20);

See output is same but way of working is different same if we will use looping in java then we have

Four ways but goal is same but we need to decide which way is better as per requirements.

Now first to fall we will solve above problem with help of while loop.

here is a link for that…

http://onlinetutorial.co.in/while-loop-in-java/

Now we will solve above problem with help of do while loop.

100 thoughts on “Looping in java

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. A powerful share, I simply given this onto a colleague who was doing a bit evaluation on this. And he actually bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love studying more on this topic. If potential, as you develop into experience, would you mind updating your weblog with extra particulars? It is extremely helpful for me. Massive thumb up for this blog put up!

  2. I and also my buddies appeared to be looking through the best helpful tips on the website and then instantly I had an awful suspicion I never thanked the site owner for those techniques. These young boys appeared to be stimulated to learn all of them and have very much been taking advantage of these things. Thanks for truly being very kind and for finding variety of notable subject areas millions of individuals are really eager to understand about. My sincere regret for not saying thanks to earlier.

  3. I absolutely love your blog and find the majority of your post’s to be just what I’m looking for. Do you offer guest writers to write content in your case? I wouldn’t mind composing a post or elaborating on a number of the subjects you write in relation to here. Again, awesome site!

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.