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!
These videos are very useful for us beginners. Thank you!
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
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);
}
Youve just given me hope again. Youre such a natural. Thank you very much
Excelent video, very helpfull to newbies like me!
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
You are amazing. Your knowledge and delivering skill is amazing
Thank god I can finally organize my fridge.
Wow man, thank you for making this! It really helped
Short, Simple & Effective. Thanks a ton.
Like a mini skirt
thanks for this great tutorial series
Wow!!! im learning❤❤❤ keep it up bro, such a big help for beginners like me.😊
thanks brother we appreciate your efforts ....best of luck
Thank you dude! Now I can write my homework and know more about classes and objects!
Straight to the point nice video♥️
Thank you! This helped me out.
Completely understood, also with for loop for int numbers this time. 31th. Thank you, ma Bro Sensei!
best videos about programming
Amazing!!!
Thanks a whole lot for this!
Well done explained.
Good video, thanks
Good video as always
Great video bro
Bro is coming in clutch for my cs final tomorrow -- Thank you!
thanx for the help!
Liked it sm
Thanks, Bro! ☕ You're awesome!
Thanks, Bro!
I loved it
Thank you so much sir.
Good content!
Thnak you for all your help
Great video
Perfect!
Thanks, bro.
Thanks!!
This is really great can you do one where the object array can hold objects of different types (non-primitive objects)?
tyanks for your help
Thank you!
Another banger lesson
Thanks!
Thank you Bro
Thanks bro
Very helpful
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();
}
nice👌🙌
Thanks men
Nice.
Good goody!
thank you bro
Thanks🎉🎉🎉😊
best brooo
thanks bro
nice 1
Great
👌👌
Thank you
🙏🏻
thank you my Bro ♥♥♥
عربي ؟
❤❤❤
noice
lets gooooo
🍱👍
Nice
👍
💙
Thanks
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
nice
thanks
i just punched the like button because of One Punch Man.
nais
I need this @ Number 9
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?
Can I create an arrayList of objects?
But how do I enter new value inside the array object
gg
I am a heroooo
Thankssssssss
Very well explained!
thanks for watching Heisenberg!
Lets get this bread
i like food
how do automatically create an object? what if you allow the user to add a food? how to auto create food4
🙃
Is this array bag?
learnt
Like and comments
Being formal, isn’t an array of objects technically called an ArrayList?
Where do you study Bro ?
West Jett
i like beans
Java seems easier than python
Is pizza your favorite food, cause you mention about it everytime
thanks. but unable to understand
sometimes it seems that you work as an ambassador of pizza companies. But I doesn't matter, as usual thanks