do you have to declare each object in the array like you did with the class ob1 = new class; or is there an easier way to do it like how you can declare int arrays with a simple for loop?
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
No, it didnt work, ive just tried it and I caught an error. I dont know why, buy it doenst work P.s this is my code if you want to look at: public class Main { public static void main(String[] args) { Food[] refrigerator = new Food[3]; Food food1 = new Food("pizza"); Food food2 = new Food("hamburger"); Food food3 = new Food("hotdog"); refrigerator [0] = food1; refrigerator [1] = food2; refrigerator [2] = food3; for (int i = 0; i
@@Golosovtalks You forgot to input the 'name' in the println statement, it shows the address of the food only if u not include name, hope this can helps for(int i=0; i
bro ur an absolute g. I'm watching and following along with every video in ur java playlist and ur seriously filling in gaps. Im gonna use ur vids for the other languages as well. thanks bro
1:41 I don't understand why he is telling, "give a size if we do not plan assigning values right away". I m wondering arrarys are fixed if we declare size at the initialisation, meaning he have plan to assign 3 values at this program hence he is giving size 3. Is there a way he can increase the size dynamically during the run time if the array size is declared at the initialisation? Pls help to advise if I m missing something.
//******************************************************
public class Main {
public static void main(String[] args) {
//Food[] refrigerator = new Food[3];
Food food1 = new Food("pizza");
Food food2 = new Food("hamburger");
Food food3 = new Food("hotdog");
Food[] refrigerator = {food1,food2,food3};
//refrigerator[0] = food1;
//refrigerator[1] = food2;
//refrigerator[2] = food3;
System.out.println(refrigerator[0].name);
System.out.println(refrigerator[1].name);
System.out.println(refrigerator[2].name);
}
}
//******************************************************
public class Food {
String name;
Food(String name){
this.name = name;
}
}//******************************************************
do you have to declare each object in the array like you did with the class ob1 = new class; or is there an easier way to do it like how you can declare int arrays with a simple for loop?
@@nikleduc1158 You can also do for loops :D
The laziest person who copy this text files :)
Insane this is 3 years old but has done the best job at explaining how to get this done. Bravo!
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
Thank god I can finally organize my fridge.
These videos are very useful for us beginners. Thank you!
Short, Simple & Effective. Thanks a ton.
Like a mini skirt
You are amazing. Your knowledge and delivering skill is amazing
You can print all three elements using for loop
for(int i = 0; i < 3; i++) {
System.out.println(refrigerator[i].name);
No, it didnt work, ive just tried it and I caught an error. I dont know why, buy it doenst work
P.s this is my code if you want to look at:
public class Main {
public static void main(String[] args) {
Food[] refrigerator = new Food[3];
Food food1 = new Food("pizza");
Food food2 = new Food("hamburger");
Food food3 = new Food("hotdog");
refrigerator [0] = food1;
refrigerator [1] = food2;
refrigerator [2] = food3;
for (int i = 0; i
@@Golosovtalks You forgot to input the 'name' in the println statement, it shows the address of the food only if u not include name, hope this can helps
for(int i=0; i
You can also do that with
for (Food i: refrigerator) {
System.out.println(i.name);
}
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
best videos about programming
Well done explained.
Youve just given me hope again. Youre such a natural. Thank you very much
Bro is coming in clutch for my cs final tomorrow -- Thank you!
bro ur an absolute g. I'm watching and following along with every video in ur java playlist and ur seriously filling in gaps. Im gonna use ur vids for the other languages as well. thanks bro
Thank you dude! Now I can write my homework and know more about classes and objects!
Completely understood, also with for loop for int numbers this time. 31th. Thank you, ma Bro Sensei!
thanks brother we appreciate your efforts ....best of luck
Wow man, thank you for making this! It really helped
Thank you! This helped me out.
Excelent video, very helpfull to newbies like me!
if you have to create 30+ objects can you use a for loop to instantiate them?
Sure, something like this might work
Car[] cars = new Car[30];
for(int i = 0; i < 30; i++) {
cars[i] = new Car();
}
tyanks for your help
Amazing!!!
thanks for this great tutorial series
thanx for the help!
Straight to the point nice video♥️
This is really great can you do one where the object array can hold objects of different types (non-primitive objects)?
I loved it
nice 1
Wow!!! im learning❤❤❤ keep it up bro, such a big help for beginners like me.😊
Great
Thanks, bro.
Thanks, Bro!
Liked it sm
Good video, thanks
Great video bro
Thanks bro
Good video as always
Good goody!
best brooo
Very helpful
❤❤❤
Thanks🎉🎉🎉😊
Thanks a whole lot for this!
Nice
Thanks!
Nice.
Great video
Bro code the best
lets gooooo
Good content!
nice👌🙌
🍱👍
noice
👌👌
Thnak you for all your help
Thanks, Bro! ☕ You're awesome!
Perfect!
Another banger lesson
nice
Thanks!!
Thank you so much sir.
💙
name is in the Food class object. So how it is associating with main class when you are printing the food name.
Can you explain it please?
Thank you Bro
Thanks men
thank you bro
i just punched the like button because of One Punch Man.
Thank you!
Thanks
🙏🏻
Is this array bag?
thanks
👍
how do automatically create an object? what if you allow the user to add a food? how to auto create food4
Thank you
thank you my Bro ♥♥♥
عربي ؟
Can I create an arrayList of objects?
Lets get this bread
gg
i like food
Thankssssssss
Very well explained!
thanks for watching Heisenberg!
1:41 I don't understand why he is telling, "give a size if we do not plan assigning values right away". I m wondering arrarys are fixed if we declare size at the initialisation, meaning he have plan to assign 3 values at this program hence he is giving size 3. Is there a way he can increase the size dynamically during the run time if the array size is declared at the initialisation? Pls help to advise if I m missing something.
Using arraylists, you can change the size during runtime
Java seems easier than python
But how do I enter new value inside the array object
I need this @ Number 9
Is pizza your favorite food, cause you mention about it everytime
nais
I am a heroooo
🙃
Being formal, isn’t an array of objects technically called an ArrayList?
learnt
West Jett
thank you so much, you actually explain things much better than my teacher 🤍
Like and comments
sometimes it seems that you work as an ambassador of pizza companies. But I doesn't matter, as usual thanks
Thanks, Bro 06/08/2024