#33 Enhanced for Loop in Java

แชร์
ฝัง

ความคิดเห็น • 35

  • @GG-hk5iz
    @GG-hk5iz 4 หลายเดือนก่อน +11

    the best part of your teaching is that videos are short and covers everything so one doesn't get bored

  • @Faraz-cse
    @Faraz-cse ปีที่แล้ว +6

    Thanks for explaining with Arrays of Student type too. 👍🏻

    • @vinitha1432
      @vinitha1432 ปีที่แล้ว +3

      for(Student stud : students) How the word Student can come there as we need to give the datatype for student. String/int etc

    • @meherprudhvi9368
      @meherprudhvi9368 10 หลายเดือนก่อน +1

      @@vinitha1432 anything that belong to classes is a class data type, for example class student { int m; } any variable declared inside class is student datatype

  • @royalgamingmdk5706
    @royalgamingmdk5706 ปีที่แล้ว +5

    Please make a video on problem solving in java

  • @RagnarLothbrok-sq8fj
    @RagnarLothbrok-sq8fj 3 หลายเดือนก่อน

    THANK YOU SO MUCH sir....for helping me out with the coding.Grateful for you ever.

  • @christyaldridge3839
    @christyaldridge3839 5 หลายเดือนก่อน +1

    Beautiful.. simple and concise... just brilliant

  • @rifikagarigipati2358
    @rifikagarigipati2358 หลายเดือนก่อน +1

    This is my first comment on TH-cam
    Just I wanna say ....
    Thank you sir

  • @SwinkMediaHouse
    @SwinkMediaHouse หลายเดือนก่อน

    Great explanation… thx for sharing!

  • @russhensel
    @russhensel ปีที่แล้ว +2

    Similar to the long time basic for loop in Python. ( and I gather other advanced languages )

  • @Cladxz12
    @Cladxz12 6 หลายเดือนก่อน +1

    Fist, great video and explanation! Thank you so much for all this.
    I'd like to ask you and guys in the comment about how do you uncomment all those section by simply selecting them and press a button! Im very curious about this handy shortcut! Im a windows user maybe thats why I find it such a cool feature, maybe only for mac users ahahah.
    Again thx for the video, got it all clear :D

    • @sabinemulder1093
      @sabinemulder1093 5 หลายเดือนก่อน +1

      In NetBeans it is: Ctrl + Shift + C , I don't know if that works for all IDE's

    • @deepadevi8911
      @deepadevi8911 5 หลายเดือนก่อน

      Use ctrl+ / for window or command +/ on mac

    • @md.ikramulislam9708
      @md.ikramulislam9708 หลายเดือนก่อน

      @@deepadevi8911 thanks man

  • @thecodingconcept
    @thecodingconcept 7 หลายเดือนก่อน

    you are an amazing teacher.

  • @NaL50_
    @NaL50_ 5 หลายเดือนก่อน

    U helped on my Ap exam today ty

  • @sidratulmoontahasubha724
    @sidratulmoontahasubha724 3 หลายเดือนก่อน

    You can say range for loop

  • @raviteja-u9u
    @raviteja-u9u 9 หลายเดือนก่อน +1

    why you given student in place of string or int in enhance for loop can u explain for me pls sir

    • @sachinkotian6250
      @sachinkotian6250 9 หลายเดือนก่อน

      for type of every iteration

  • @chaitanyathorat8429
    @chaitanyathorat8429 ปีที่แล้ว +1

    Great videos sir

  • @RameshMaity90
    @RameshMaity90 5 หลายเดือนก่อน

    Total Array including Enhanced for loop concept :-
    public class Array {
    public static void main(String[] args) {
    int num1[] = new int[3];
    int num[][] = new int[3][4];
    for (int i = 0; i < 3; i++) {
    num1[i] = (int) (Math.random() * 10);
    for (int j = 0; j < 4; j++) {
    num[i][j] = (int) (Math.random() * 10);
    }
    }
    System.out.println("
    Two dimensitonal Array");
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 4; j++) {
    System.out.print(num[i][j] + " ");
    }
    System.out.println();
    }
    System.out.println("One dimensitonal Array");
    for (int n : num1) {
    System.out.print(n + " ");
    }
    System.out.println("
    Two dimensitonal Array");
    for (int n[] : num) {
    for (int m : n)
    System.out.print(m + " ");
    System.out.println();
    }
    int num2[][] = new int[4][];// jagged array
    num2[0] = new int[2];
    num2[1] = new int[3];
    num2[2] = new int[4];
    num2[3] = new int[5];
    for (int i = 0; i < 4; i++) {
    for (int j = 0; j < num2[i].length; j++) {
    num2[i][j] = (int) (Math.random() * 10);
    }
    }
    System.out.println("Jagged Array");
    for (int n2[] : num2) {
    for (int m2 : n2) {
    System.out.print(m2 + " ");
    }
    System.out.println();
    }
    System.out.println("3D Array");
    int num3[][][] = new int[3][2][2];
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 2; j++) {
    for (int k = 0; k < 2; k++) {
    num3[i][j][k] = (int) (Math.random() * 10);
    System.out.print(num3[i][j][k]);
    }
    }
    }
    System.out.println();
    for (int n3[][] : num3) {
    for (int n31[] : n3) {
    for (int n311 : n31)
    System.out.print(n311 + " ");
    }
    System.out.println();
    }
    System.out.println("Object Array(String)");
    Friend f1 = new Friend();
    Friend f2 = new Friend();
    Friend f3 = new Friend();
    f1.marks = 80;
    f1.name = "Ramesh";
    f2.marks = 90;
    f2.name = "Suresh";
    f3.marks = 85;
    f3.name = "Avi";
    Friend f[] = { f1, f2, f3 };
    for (int i = 0; i < f.length; i++) {
    System.out.println(f[i].name + " | " + f[i].marks);
    }
    System.out.println("Using enhanced for loop");
    for (Friend friend : f) {
    System.out.println(friend.name + " | " + friend.marks);
    }
    }
    }
    class Friend {
    int marks;
    String name;
    }

  • @shubhambhardwaj7960
    @shubhambhardwaj7960 ปีที่แล้ว

    Thank you so much 🙏

  • @oshadhaedirisinghe1455
    @oshadhaedirisinghe1455 5 หลายเดือนก่อน

    Thank you

  • @vaibhavpalaria2372
    @vaibhavpalaria2372 ปีที่แล้ว

    sir thank such a nice video

  • @praveenasubramaniyan8087
    @praveenasubramaniyan8087 3 หลายเดือนก่อน

    How to print one student name and mark using enhanced for loop instead of print all student details?

    • @sainaidu6889
      @sainaidu6889 หลายเดือนก่อน

      you can use break after print statement

  • @nandhinim6740
    @nandhinim6740 10 หลายเดือนก่อน

    Hi.. I tried with String array and does not work. Please let me know whether will it work with String array. Also how to use in enhanced for loop to print the String array.

    • @vinitsawant9081
      @vinitsawant9081 10 หลายเดือนก่อน

      Can you share your code ??

    • @vinitsawant9081
      @vinitsawant9081 10 หลายเดือนก่อน +1

      Should work for string as well

    • @NagarajuDupati-mg3oo
      @NagarajuDupati-mg3oo 9 หลายเดือนก่อน

      public class StringArrayExample {
      public static void main(String[] args) {

      String[] fruits = new String[2];
      // Assigning values to elements in the string array
      fruits[0] = "Apple";
      fruits[1] = "Banana";
      for(String a: fruits){
      System.out.println(a);
      }
      }
      }
      try this

    • @raviteja-u9u
      @raviteja-u9u 9 หลายเดือนก่อน

      i wil share my code can u teach me where i did mistake
      @@vinitsawant9081

  • @puruagni1927
    @puruagni1927 5 หลายเดือนก่อน

    Why are you not updating VS Code? Please update VS Code.

  • @bonisuribabu2401
    @bonisuribabu2401 ปีที่แล้ว +1

    That was not working

  • @kvelez
    @kvelez ปีที่แล้ว

    public class Main{
    public static void main(String[] args) {
    Student stud = new Student();
    stud.roll = 1;
    stud.marks = 88;
    stud.name = "Kevin";
    Student stud2 = new Student();
    stud2.roll = 2;
    stud2.marks = 78;
    stud2.name = "Marco";
    Student stud3 = new Student();
    stud3.roll = 3;
    stud3.marks = 90;
    stud3.name = "Justin";
    Student[] students = new Student[3];//Array with references
    students[0] = stud;//Manual objects
    students[1] = stud2;
    students[2] = stud3;
    for (Student student : students) {
    System.out.print(student.name + " " + student.roll + " " + student.marks + "
    ");
    }
    }
    }
    class Student {
    int roll;
    int marks;
    String name;
    }

    • @jasemin3335
      @jasemin3335 11 หลายเดือนก่อน

      Does this work?