@@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
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
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.
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
the best part of your teaching is that videos are short and covers everything so one doesn't get bored
Thanks for explaining with Arrays of Student type too. 👍🏻
for(Student stud : students) How the word Student can come there as we need to give the datatype for student. String/int etc
@@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
Please make a video on problem solving in java
THANK YOU SO MUCH sir....for helping me out with the coding.Grateful for you ever.
Beautiful.. simple and concise... just brilliant
This is my first comment on TH-cam
Just I wanna say ....
Thank you sir
Great explanation… thx for sharing!
Similar to the long time basic for loop in Python. ( and I gather other advanced languages )
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
In NetBeans it is: Ctrl + Shift + C , I don't know if that works for all IDE's
Use ctrl+ / for window or command +/ on mac
@@deepadevi8911 thanks man
you are an amazing teacher.
U helped on my Ap exam today ty
You can say range for loop
why you given student in place of string or int in enhance for loop can u explain for me pls sir
for type of every iteration
Great videos sir
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;
}
Thank you so much 🙏
Thank you
sir thank such a nice video
How to print one student name and mark using enhanced for loop instead of print all student details?
you can use break after print statement
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.
Can you share your code ??
Should work for string as well
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
i wil share my code can u teach me where i did mistake
@@vinitsawant9081
Why are you not updating VS Code? Please update VS Code.
That was not working
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;
}
Does this work?