Java Tutorial: The for Loop in Java
Вставка
- Опубліковано 5 вер 2024
- Java For Loop Tutorial: This java tutorial on for loop will teach you about how to use the for loop in java. The for loop in java is about the initialization, condition and the updating. This video explains how each of these things work in java!
►This playlist is a part of my Complete Java Course playlist: • Java Tutorials For Beg...
►Source Code + Notes - codewithharry....
►Ultimate Java CheatSheet: codewithharry....
►Checkout my English channel here: / programmingwithharry
►Click here to subscribe - / @codewithharry
Best Hindi Videos For Learning Programming:
►Learn Python In One Video - • Python Tutorial In Hin...
►Python Complete Course In Hindi - • Python Tutorials For A...
►C Language Complete Course In Hindi -
• C Language Tutorials I...
►JavaScript Complete Course In Hindi -
• JavaScript Tutorials I...
►Learn JavaScript in One Video - • JavaScript Tutorial
►Learn PHP In One Video - • Learn Php In One Video...
►Django Complete Course In Hindi -
• Python Django Tutorial...
►Machine Learning Using Python - • Machine Learning Tutor...
►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
►Advanced Python Tutorials - • Intermediate/Advanced ...
►Object Oriented Programming In Python - • Object Oriented Progra...
►Python Data Science and Big Data Tutorials - • Python Data Science an...
Follow Me On Social Media
►Website (created using Flask) - www.codewithhar...
►Facebook - / codewithharry
►Instagram - / codewithharry
►Personal Facebook A/c - / geekyharis
Twitter - / haris_is_here
Sir I literally spend most of my time with you on laptop😂😂
Literally 😂😂
Actually...😂😂😂😂
same bro
How can i get the notes link?
Be kaunsa laptop jiski battery khatam nahi hoti hai 😀😀
He is making so much efforts and the least we can do is like and share this videos. 🙂
yeah
pehle pdh lo
Course is getting more exciting and it's great that you are teaching us JAVA
I literally got 50/80 in my final in comp by watching your videos.becsuse I got 7 / 80 in my second term and now I am working hard ..Thank uu very much 🙏
Mera bhi halaat tumhare jaisa tha, fir mene videos wagera dekhe aur 60 up Marka milne lag Gaye (out of 80).
Icse?
@@carsimulater2475 i am in class 10 icse and i am watching his playlist😂😂😂
@@sunitashaw3818 is java in icse
@@sunitashaw3818 so?
Thumbnail of these videos looks like a scared nursery kid trying to hide from the teacher behind his notes....to avoid the punishment😂😂😂
🤣you made me smile
Lol yeh
Nahi le ge
Kya kar lega punishment bhag chutuya
Oh Bhai kya bol diye
6:55 answer
Scanner input = new Scanner(System.in);
System.out.println("range of odd numbers :");
int rang = input.nextInt();
for (int i=0; i < rang; i++){
if (i%2 != 0) {
System.out.println(i);
}
}
Print (" Harry sir is the best teacher for computer science")
Who agree hit like 👍
This will show an error!
Use ('''
''')
while(true){
System.out.println(" Harry sir is the best teacher for computer science");
}
@@vaibhav3852 I am taking about python
@@soletsk5761 bro java ka coursee ha python ka nahi
भावा तुझे वीडियो रोज बघतो Love From महाराष्ट्र💐
me too from maharastra
@@reactionboi758 me too from mumbai
Ek no video ahet heche👍🏻
मी ते hyderabad वाल्यांचे accent ऐकून कंटाळलो होतो 😜
Me to from MH 28
7:46 you could also use the "i+=2" function to print odd numbers just by starting the loop from "1"
yeah also this simple piece if code
int n=20;
for(int i=1; i
Hey guys, but the question is to print n odd numbers and not to print odd numbers less than n...
Suppose, if n = 5
for(i=1; i
yeah!
@@alvaaaas for ( int i = 0; i
yes
only a teacher in my who teach better then everyone.... God bless you harry sir...
Found a recommendation to your Channel on Reddit and thank God I did. Thank you for your videos.
same
Great. Harry Bhai, you always make a smile on our face everytime. This revolution is going to be legendary.🙇🏻♂️🙇🏻♂️
WHAT I DIDNT LEARN IN MY SCHOOL IN 3 YEARS , I LEARNED IN ONLY FEW DAYS FROM HARRY BHAIYA !!!! THANKYOU BHAIYA GREAT VIDEO
cuz u are not interested that time
@@letsfunwithme1779fck true 😂
18:27
for (int n = 10; n>0; n--){
System.out.println(n);
}
Sir done!!
int n =15;
for( i=1; i
18:12
17:49
import java.util.Scanner;
public class ForLoop {
public static void main(String[] args) {
Scanner naturalNumber = new Scanner(System.in);
System.out.print("Enter the total number of natural numbers
that you want to print in reverse order: ");
int num = naturalNumber.nextInt();
for (int i = num; i != 0; i--) {
System.out.println(i);
}
}
}
i- - 😆😉
@@_sameerpandey it's a small mistake but big problem😅
13:36
Yes,it would be valid...the output would be negative numbers,also int is used in the program (int i=5)so there will be no problem while executing the program.The output would be negative numbers i.e integers up to the limit set(in this case it was 5)
No bro, it is an infinite loop. From 5 to infinity.
Wow.....really great explanation got the concept of for loop really well
18:04 =
public class PracticeSet05 {
public static void main(String[] args) {
int n = 10;
System.out.println("First n natural numbers are: ");
for(int i=0; i=0; i--){
System.out.println(i);
}
}
}
👍🤛
n-1????
Bss n hoga
bhai n-1 bhi sahi hai kyuki woh n ko inlcude nhi kar rha it depends on the users choice
@@AcceptableAxe sahi nahi hai n-1 will print 49 to 1 in reverse excluding 50.
Hi Harry...I am new to your channel and to be very honest your content is up to mark....to brush up Java concepts your videos are really helpful for beginners.......
Because of you I am consistently coding java from 2 weeks 👍👍👍👍👍👍👍🤩🤩🤩🤩🤩🤩🤩🤩 Thanks 😊
17:54
// Decrementing for loop:
System.out.print("Enter a no. to print the natural nos. upto n: ");
int f1 = sc.nextInt();
System.out.println("Printing the natural nos. in reverse order:");
for (int f = f1; f > 0; f--) {
System.out.println(f);
}
18:00
Scanner sc = new Scanner(System.in);
System.out.println("Enter value of n (Natural number in REVERSE order)");
int n = sc.nextInt();
int i;
for (i=n;i>0;i--)
System.out.println(i);
Thanks ♥
B
10:10 We can Simply User : -
for (int e=1; e
Bhai I am class 9 student , learner complete python , c from you and java , but I want to use this knowledge , I want to earn some money , Pls make a video on how student such as me who are not eligible for job can earn with their programming knowledge ....
@@vedantnn7 Thanks , hope Harry will make a video on it!
Bro, i was in 8th when i started i used to make websites and some GUI application you can try but i didn't do that for money *_*
Ya buddy same here
I am also in class 9 or chhar languages aati hai but use Kaha Karu samajh nhi aati
@@vedantnn7 same bro 7th class. I also think same.
Yeah that's good but if you will get money you will be proud of you that what you are doing is actually worth it.
And not like hindi and Sanskrit 😂😂😂
question 4 pattern 2=
public class fair {
static void pattern(int n){
for(int i=0;i
18:14
// Quick Quiz--->
System.out.println("How many reverse natural no.s do you want to print?");
for (int i = sc.nextInt(); i>0; i--){ //*** (i!=0)--> stopping condition.
System.out.println(i);
}
Dear Sir, I am Jatan Thanki and this is the answer of the Quick Quiz and I also I wanted user input so I just slightly changed the answer then the normal variable. I hope you like it!
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
// The For Loop
// Quick Quiz
Scanner console = new Scanner(System.in);
System.out.println("Please enter a number " +
"to find all the numbers that are smaller than it "+
"and to print them in reverse order"
);
int n = console.nextInt();
for(int i = n; i>=0; i--){
System.out.println(i);
}
}
}
Please do find any mistakes so that I can fix it:)
Shouldn't it be i>=1 since its natural numbers
Thank you very much brother
harry sir your teaching is very impressive and my all doubts are clear it happened because of you
Thank you very much Harry Sir, I have written the first program of my college's java course by your helpful teaching. Thanks a lot ❤
Thanks sir for this playlist
You are really great
Sir apka bahot bada fan ban gaya hoon.. 🙏😊
Thanks harry bhai for this course and the knowledge you given.
Sir thank-you very much your videos helped me a lot❤️
Hats off To Your Dedication Bhai ! And Pankhe Ghumege Laptop Drone Ban Jayga Was Epic HEHE
We can also print odd using (2n+1) in place of i
//print first 10 odd numbers
int n=0;
for(int i=0;i
19:08 bro it will only print 4 odd nors because ur I is 5
in the odd number question of for loop ,i've used for and if statement cause it was a good way for revision:
for(int i = 1;i
18:21
System.out.println("First 50 natural number in reverse order : ");
for (int a = 50 ; a >= 1 ; a--){
System.out.println("natural number "+a);
}
But natural number start from 0
@@LiquiditySniper no bro its correct ..
Whole no starts with 0.
@@userazad8137 ohh I'm confused
Good Bro 🤜
You Write Int Under The Loop 🔁And Im Out Side of Loop
18:24
public class Loop {
public static void main(String[] args){
Scanner sc= new Scanner(System.in);
System.out.println("Enter");
int b =sc.nextInt();
for (int a=b; a!=0; --a)
{
System.out.println(a);
}
}
}
nice
😏
Lovelyy bro❤️❤️❤️❤️i really wonna have live discussions with u😍😍
THANK YOU BHAIYA i understand the how is work loop body in program?
System. out. print ("Thanks sir for your java playlist you are awesome");
respect++;
18:20
public class Main {
public static void main(String[] args) {
int n=1;
for(int i=10;i>=n;i--){
System.out.println(
i
);
}
}
}
Really I appreciate your hard work. Thanks harry sir
Well said . 💯 True. 👍👍
For loop is the Easiest I prefer to use it instead of any other
17:53
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of limit (n) :");
int n = sc.nextInt();
System.out.println("First " +n+ " natural numbers in reverse order ");
for (int i=n;i>0;i--){
System.out.println(i);
}
Nicely done
sach btana scanner use krne me maza aata h na..🤣
13:37 - This will create an infinite loop as your condition always remains true.
Sir u are just amazing ❤️🙏Thank you so much ...seriously,,some students Students like me can learn something for you😀
18:25
For(int i=n;i>0;i--)
13:38
it will print all the numbers from 5 onwards it'll be an infinite loop
18:20
package org.example;
public class Main{
public static void main(String[] args) {
for (int i = 100; i > 0; i -= 1){
System.out.println(i);
}
}
}
Program for the quiz mentioned at 17:48
public class loop_practice {
public static void main(String args[]){
int i;
for(i=5;i!=0;i--){
System.out.println(i);
}
}
}
Why did you take i=5, it is saying first "n" natural numbers. You need to take input from user as n, n can be 10,20 or even 1000
Decrement natural numbers 1 to 100 using for loop
class demo{
public static void main(String args[]){
for(int i = 100; I
17:48 *Here is the program*
import java.util.Scanner;
public class Natural_Number_Printer_Reversed{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
System.out.println("This program prints the natural number in reversed order from the given number");
System.out.print("Enter the natural number to start from: ");
int num = sc.nextInt();
for (int i = num; i > 0; i--){
System.out.println(i);
}
}
}
Great
@@realheckertrustmebro Thank You ˶ᵔ ᵕ ᵔ˶
@@shivu6377 actually, thank youu
@@realheckertrustmebro Why?
@@shivu6377 👀it helped. Thats why
One heart to Banta h harry bhai aur waise bhi ye course whit hat jr se Lakho achha h.....
Please upload Data structures course more frequently 🙏
Harry sir,you didn't complete the syllabus of DS nd algorithm .its humble request to you please provide the remaining videos of Data structure and algorithm.🙏🙏
17:51
Quick quiz ans-
int n = 7;
for (int y=1; y
11:45 I am thinking about this program since a long time..
Everyone told only that general formula like n%2!=0..
But today I found that ..
Thank you Harry Bhai
Brother this general formula is used to check whether a number is even or not but the formula that Harry told is to print even number or odd
Yo vid 23 let's go
Thank you sir 😊
" one of the people who like this will be a billionaire one day "
" Good Luck " 😂😂
" Lallantap " 🎉🎉
" Lallantap Video "👍👍
Bandbudh or Budbak
chutiye yaha bhi hai
those who dislike the video must be Paid tution tutors.
thanks for the vdo
int p = 10;
for(int i = p; i>=0 ; i-- )
System.out.println(i);
Mam you are completed to all this java playlist 😮💨
10 To 0 print
18:25
package java1;
public class for_loop01 {
public static void main(String[] args) {
for (int i = 10 ; i>0 ; i--){
System.out.println(i);
}
}
}
// DONE HAI JI
Day 14 of commenting until Harry bhai makes a PyQt5 tutorial
Dedication OP
18:11
//Program to print first n natural numbers in reverse order: (Reverse Loop)
System.out.print("Enter the range of numbers: ");
int num = sc.nextInt();
for(int i=num; i>=1; i - -){
System.out.println(i);
}
Who is watching this during online classes 😂😂.
Me
I
School is useless 😂😂😂😂😂😂
Onlone Nahi Bhai online hota hai
package Practice;
import java.util.Scanner;
public class forLoop {
public static void main(String[] args){
System.out.print("Enter a number: ");
Scanner s1 = new Scanner(System.in);
int n= s1.nextInt();
for(int i=1; i
Mazaaaa Aa gyaaaaaa Harrrrrrissssss Bhaiiiiii and i will seee youuuuuuuuuuu nextttttttt timeeeeee...........!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10:10 harry bhai app also if condition lagake check odd number print karwa sakte ho ise she if else condition bhi revise ho jayega
import java.util.Scanner;
public class CHW_23_fore_loop {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int i;
int i2 =10;
System.out.println("Enter a number");
for ( i = sc.nextInt(); i < i2; i++){
System.out.println(i);
}
}
}
17:51 quick quiz answer
for(int i=5; i>=0; i--){
System.out.println(i);
}
Harry you are the best teacher on youtube
18:13
{
System.out.println("Enter a Number");
Scanner a = new Scanner(System.in);
int num = a.nextInt();
System.out.println("Natural Numbers in reverse Upto "+num);
for (int i = num ;i>0; i-- ) {
System.out.println(i);
}
Good👍
10:45
More optimize code
public class OddNumbers {
public static void main(String[] args) {
int limit = 10;
System.out.println("Odd numbers from 1 to " + limit + ":");
for (int i = 1; i
18:11
int n = 0;
for(int i = 5 ; i>n ; i --){
System.out.println(2n*i);
}
18:25
// Printing natural numbers till 100 (reverse)
public class Main{
public static void main(String[]args){
for(int i=100;i>0;i--){
System.out.println(i);
}
}
}
Thank you
public static void main(String[] args) {
System.out.println("Enter");
Scanner sc = new Scanner(System.in);
//int f = sc.nextInt();
int g = 0;
for ( int i = sc.nextInt(); i>g; i-- ) {
System.out.println(i);
}
}
}
Thank you bhaiya
18:27
Int i=n
For(i=10; i>n;i--){
Print "i"
Awesome sir it's understandable
18:22
int n = 0;
for(int i=10;i>n;i--){
System.out.println(i);
We can also use like this to print 5 odd numbers:
for(int i=1; i
Videos are very nice and clear
18:10
Import java .util.Scanner;
Class quiz{
Public static void main ( Stri g args []){
Scanner sc= new Scanner (System.in);
Int n= sc.nextInt();
System.out.println("enter the value ");
For( int i =n; i>0;i--){
System.out.print(i);
}
}
18:04
public class Odd
{
public static void main(String args[ ])
{
int n = 0;
for (i = 5; i > n; i--)
System.out.println(i);
}
}
}
13:40
According to me the condition will always remain true when you have written for(int i=5; i>0;i++) so it may run infinitely.
17:51
System.out.println("Understanding the decrementing for loops");
for (int i = 10; i >0 ; i--) {
System.out.println(i);
}
Class program
{
Public static void main(string args[])
{
int i
For(i=1;i>=10;i--)
S.O.P("the value of i=",")
}
}
}
it is very excited to learn java from you.
18:22 timming
quick quiz3
for(int i = 10;i>=1;i--){
System.out.println(i);
17:49 Quiz answer:
int a = sc.nextInt();
for (int i=a; i>0; i--){
System.out.println(i);
17:46
Quick quiz:
int n = 10;
for (int i = n; i>0; i--){
System.out.println(i*2);
7:56 for (int i=1;i
18:12
System.out.println("Enter the number from which you want print the numbers: ");
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
System.out.println("Enter the number upto which you want print the numbers: ");
int n = sc.nextInt();
for ( i=10 ; i>=n; i--) {
System.out.println(i);
}
Dhanyavaad Bhai!!
Jai Hind!!
18:09
n Natural numbers in reverse order:
for(int i=n ; i>0 ; i--){
System.out.println(i);
}
I think this is wrong
To print first n natural numbers in reverse order :
public class Program
{
public static void main(String[] args) {
for (int i=9;i>0;i--){
System.out.println(i);
}
}
}
18:46 System.out.println("enter the n ");
int n = sc.nextInt();
int q;
for (q=n;q>0;q--) { // jahan se jahan tak loop chaiyeh hai weseh likhte hai
System.out.println(q); // and make sure koi logical error na ho .
}
7:46 I am loving this course