Navigate Select ESC Close

#19 For Loop in Java

2023-01-16 Science & Technology
241.1k
2.8k
46
Telusko
Telusko
2.8m subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

Check out our courses: Java Spring Boot AI Live Course: https://go.telusko.com/JavaSpringBootAI Coupon: TELUSKO20 (20% Discount) AI Powered DevOps with AWS - Live Course :- https://go.telusko.com/AIDevOps-AWS Coupon: TELUSKO20 (20% Discount) Master Java Spring Development : https://go.telusko.com/masterjava Coupon: TELUSKO20 (20% Discount) For More Queries WhatsApp or Call on : +919008963671 website : https://courses.telusko.com/ Udemy Courses: Spring: https://go.telusko.com/udemyteluskospring Java:- https://go.telusko.com/udemyteluskojava Java Spring:- https://go.telusko.com/Udemyjavaspring Java For Programmers:- https://go.telusko.com/javaProgrammers Python : https://go.telusko.com/udemyteluskopython Git : https://go.telusko.com/udemyteluskogit Docker : https://go.telusko.com/udemyteluskodocker Instagram : https://www.instagram.com/navinreddyofficial/ Linkedin : https://in.linkedin.com/in/navinreddy20 TELUSKO Android App : https://go.telusko.com/TELUSKOAPP TELUSKO IOS App : https://apple.co/3SsgmU2 Discord : https://discord.gg/D8hWe9BqfF In this lecture we will learn: - Overview of a while loop - For loop and its point - Syntax of for loop - Nested for loops #1 -In the while loop we have three things: Initialization, Condition, and then increment. -We do these three things in different lines in a while loop. -Sometimes we do not know about the ending point, where this loop will get end. As it may end based on some conditions. #2 - In the finite loop, we know about its starting and ending. - For loop supports three different statements in one line. - We can put initialization, condition and increment in one single line in for loop. - It is mostly used when the number of iterations is fixed. - Because of the binary format computer starts from 0. - So, in general, we start from 0 and end at count-1 ie., one less than the total number of iterations. - Loops are very useful when we have to print some pattern or want to print things repeatedly. #3 Syntax of For Loop:- for(initiation; condition; incrementation or decrementation) { statements; } * init - The init expression is used for initializing a variable, and it is executed only once. * condition - It executes the condition statement for every iteration. If it evaluates the condition to be true, it executes the body of the loop. The loop will continue to run until the condition becomes false. * incr/ decr - It is the increment or decrement statement applied to the variable to update the initial expression. - First initiation and condition statement execute and then execution of statements takes place and then increment takes place at last. - We can also skip any of the three parts as per the need. #4 Nested For loops:- - We can also use nested for loops as same as while loop. Nested loops mean loop inside a loop. - Whenever the outer loop meets the condition, the inner loop is executed completely. Github repo : https://github.com/navinreddy20/Javacode.git More Learning : Java :- https://bit.ly/3x6rr0N Python :- https://bit.ly/3GRc7JX Django :- https://bit.ly/3MmoJK6 JavaScript :- https://bit.ly/3tiAlHo Node JS :- https://bit.ly/3GT4liq Rest Api :-https://bit.ly/3MjhZwt Servlet :- https://bit.ly/3Q7eA7k Spring Framework :- https://bit.ly/3xi7buh Design Patterns in Java :- https://bit.ly/3MocXiq Docker :- https://bit.ly/3xjWzLA Blockchain Tutorial :- https://bit.ly/3NSbOkc Corda Tutorial:- https://bit.ly/3thbUKa Hyperledger Fabric :- https://bit.ly/38RZCRB NoSQL Tutorial :- https://bit.ly/3aJpRuc Mysql Tutorial :- https://bit.ly/3thpr4L Data Structures using Java :- https://bit.ly/3MuJa7S Git Tutorial :- https://bit.ly/3NXyCPu Donation: PayPal Id : navinreddy20 https://www.telusko.com

Top Comments (10)

@munib2023 2023-01-17

Please sir make Data Structure and Algorithm Course in Java.

63 2 replies
@BetterSachet 2023-10-18

real-time examples are very confusing sometimes it all messes up , better if you have some prepared examples but really I enjoy your lectures sir and learn something extra !

13
@shreyasshahu1423 2024-08-14

Calendar with AM and PM supported : class Hello { public static void main(String args[]) { for (int i = 1; i <= 5; i++) { System.out.println("Day " + i); for (int j = 9; j < 18; j++) { int endTime = j + 1; System.out .println( " " + (j > 12 ? j - 12 : j) + (j >= 12 ? " PM" : " AM") + " - " + (endTime >= 12 ? (endTime == 12 ? endTime : endTime - 12) + " PM" : endTime + " AM")); } } } }

6
@DipakShende-oe9pn 2024-02-04

🎯 Key Takeaways for quick navigation: 00:00 🔄 *For Loop Introduction* - Introduction to the for Loop in Java. - Comparison with while loop structure. - Overview of initialization, condition, and increment statements in for Loop. 01:13 🔄 *For Loop Syntax* - Explanation of combining initialization, condition, and increment statements in a single line. - Differentiating for Loop from while loop regarding this syntax. - Practical demonstration of a simple for Loop example. 02:35 🔄 *Working of For Loop* - Understanding the execution flow of for Loop. - Demonstrating the role of initial value, condition check, and increment in a for Loop. - Practical example of printing values in both increment and decrement order. 04:51 🔄 *Common For Loop Syntax* - Introduction to a common syntax for for Loop with initialization, condition, and increment statements. - Clarification on using "less than" for ending at a specified value. - Practical example of printing values starting from zero and ending before four. 05:59 🔄 *For Loop for Building a Calendar* - Demonstrating a practical example of using for Loop to build a weekly calendar. - Nested for Loop usage for printing hours in a day. - Addressing challenges and debugging issues during the example. 11:19 🔄 *Execution Sequence in For Loop* - Explanation of the execution sequence in a for Loop. - Debugging demonstration to showcase the order of execution. - Flexibility to skip the initialization or increment statement in the for Loop structure. Made with HARPA AI

3
@aishikmondal350 2023-08-31

Sir you are excellent. 😊

3
@ivanzq21 2023-12-22

I like the high quality video its great

2
@divyasnarayan1803 2025-06-22

Can we not start with j=9 , and j<= 17 if u want the time from 9 to 18

2
@DenyTheZeitgeist 2024-10-13

Awesome, now I'm even more lost.

1
@shruthij5838 2023-10-04

sir please do a playlist of dsa with python

0
@Jorge0422 2023-12-13

You are awesome!!!

0

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan • All features unlocked

App screenshot