Java Video Tutorial 16

preview_player
Показать описание


In this Java Video Tutorial I'm covering the Object and Class class, along with clone. We will explore all of the methods that every object gets by default.
Рекомендации по теме
Комментарии
Автор

Thank you :) I have been programming with Java for decades. I'd say the biggest issue is finding examples that make sense to you. Very often text books, which is what I learned from, sometimes present topics in a way that causes confusion. I'd say if a concept doesn't make sense, keep looking for examples until you find one that does. Don't allow yourself to think if you aren't understanding something that it is your fault. Look for another explanation. Don't give up and ask questions

derekbanas
Автор

Nice to have teachers like you who explains Java so well, unlike college professors who are so monotone and boring to even understand and make sense of their words.

sipp
Автор

That happened because superCar is of type object which is the super class for all objects. You can't however access a method in a subclass if the superclass doesn't have that method. Since the Object class doesn't contain I getSpeed method it can't be called. Look at the beginning of the design patterns tutorial and it will make more sense

derekbanas
Автор

Sorry about the confusion. I'm just demonstrating the different ways to use clone. There isn't any other reason then for demonstration reasons. As the tutorial continues I start to actually make things with java

derekbanas
Автор

Please give me a bit more information in regards to your question and I'll help. Any subclass referred to as a vehicle can access all methods in both Vehicle and superCar. If a method is only in superCar though that method can't be accessed because Vehicle doesn't have that method. I hope that helps

derekbanas
Автор

You're very welcome :) This is just a hobby. I have a very small following, but most of the people that watch my videos seem to be very nice. Thanks for giving my videos a chance

derekbanas
Автор

no problem. Always feel free to ask questions. I'm glad you figured it out

derekbanas
Автор

A class is a blueprint for creating objects. An object isn't a class, nor is a class an object. Does that makes sense?

derekbanas
Автор

Yes that is pretty much correct. Think of fields (variables) as information about the object. Methods (functions) are things the object can do. Just like a person, or any other real world object

derekbanas
Автор

You're very welcome :) Have you tried overriding clone() and instead tried making the class implement Cloneable?

derekbanas
Автор

one of the most important tutorials that you have to know....i totally understand this now...I was always confused with hashCode, toString, Clone etc....they are very useful especially in data structures....thank you

borisjurosevic
Автор

Thank you for all the nice comments :)

derekbanas
Автор

Thank you :) I plan on making them for as long as possible. I'm glad you like them

derekbanas
Автор

Been using several resources at a time while programming to learn Java and fully understand it, and your videos are by far the best resources I've used. I thank you so much! Hate not having great examples, and college is terrible at teaching it.

Hunter-fytp
Автор

Yes
Always feel free to ask questions. Thank you for the compliments :)

derekbanas
Автор

You get this error when you call for an object that is set to null. If you look into the line the error is occurring on you'll know which object hasn't been initialized. Then initialize it so that it doesn't have the default null value. Does that help?

derekbanas
Автор

Yes a constructor that does nothing is created by default, but you'll find you often need to provide some initialization in the constructor in most real world projects

derekbanas
Автор

@supprof1 You're very welcome. Thanks for watching them :)

derekbanas
Автор

I will get into graphics programming using OpenGL very soon. C is considerably faster than Java and I'll look at using graphics using just C as well as using a wrapper for OpenGL in Java called LWJGL. LWJGL was used to create Minecraft :)

derekbanas
Автор

I did it in this video with Vehicle. I'll think about what the problem could be?

derekbanas