In this part of my Java Video Tutorial, I continue to provide you with a complete understanding of Java.
Today I’m covering the Object and Class class, along with clone. We will explore all of the methods that every object gets by default.
Use the code that follows the video to help you learn. If you missed the previous parts make sure you check them out here Java Video Tutorial.
If you like videos like this share it [nttfblike]
Code From the Video
LESSONSIXTEEN.JAVA
VEHICLE.JAVA
I am taking your tutorial at this moment, and have noticed that the ” Object superCar = new Vehicle(); ” and ” Vehicle superTruck = new Vehicle(); ” line within the L16 code both come up as errors. It would be very helpful to have some feed back on how to fix the error.
Thank You
Sincerely Ben T.W
There has to be something else wrong because that code is fine. What error are you getting?
This happened to me too, but it was because in the code for lesson 15 the Vehicle class was missing a constructor. This is added in the code above, so it all works now. Phew!
Amazing tutorials, thank you Derek!
Oops, disregard this comment! I don’t think I quite understand Java yet… ha. Was it because Line 07 in JavaLesson16 is missing the int and double arg?
thanx eddie. .me too got the same error,and created a costructor in Vehicle class. .it was gone. . Phew!!!!! 😉
The constructor in the VEHICLE class defines two parameters:
public Vehicle(int wheels, double speed) {
this.numOfWheels = wheels;
this.theSpeed = speed;
}
Adding a blank constructor can fix this:
public Vehicle(){
}
OR:
In the JAVALESSONSIXTEEN class these parameters are undefined.
Object superCar = new Vehicle();
It should be:
Object superCar = new Vehicle (4, 10);
[or whatever int and double values you would choose in place of the 4 and the 10]
hi there, I copied ur code to netbeans and I tried to run it, but no luck. do you think it is becouse I use netbeans insted of Eclipise? thanks for your advice.
this is the error I get:
Exception in thread “main” java.lang.VerifyError: (class: lessonsixteen/Vehicle, method: signature: (ID)V) Constructor must call super() or this()
at lessonsixteen.LessonSixteen.main(LessonSixteen.java:19)
This seems to be a NetBeans error. This is the fix I found online
Delete .class files from under project/build/classes.
Click Run -> Clean & Build Project
I hope that helps
Hello thnaks , do we need to copy the crashable and drivable classes to ur code for this lesson? as they are not included in ur code for this lesson.
another question I have: does it matter to name the clases with uppercase or lowercase? are Crashable different from CRASHABLE? THNAKS
Yes you need those classes and they are available here Java Video Tutorial 15. You can name your classes using different cases if you’d like, but it is common to name them per word like this ThisIsAClassName
Thanks for ur reply. 🙂
would you plz. make video tutorial series on J2EE(servelet,jsp)??
That series of tutorials is in the works now
Hi Derek!
As many of your students have already stated, and I reiterate, thank you from the bottom of my heart. What you are doing here is giving of your time and from your skill set to help others, and there is no greater gift or deed than to lend a hand to your fellow man. I am grateful for what you do and I feel a bit obligated to learn as much from you as I can, since you’re spending your time teaching us.
Now that I’ve spit-shined your sitting muscle, I have a few questions that I’d like to ask.
I love programming and I would enjoy working with a firm developing Java based software. How far off base am I to believe once I finish all 60 of your Java tutorials and I have a firm handle on the language, that I would be able to land a job using this new skill? It would be awesome, but I feel there is a lot more that I don’t know about this and I am hoping you could help me understand what employer would be looking for from me and my skill set so that I could be better prepared and enter the workforce as a competent Java programmer.
Sincerely,
William Mosley
Hi William,
Thank you for the kind message. It is very much appreciated 🙂
I tried to do something with this Java tutorial that has never been done. I tried to cover everything imaginable. I wanted to make a person willing to go through everything to be an expert on programming java, but also programming in general.
The java tutorial actually continues after the original 60 to Design Patterns, Java Algorithms, Object Oriented Design, Refactoring, UML, and now Android.
After Android apps, I’ll cover Android game development. Then I’ll cover the final part being all J2EE related topics. I’ll also probably develop straight Java Games.
If you go through all of them I’d say you will be a Java expert and an expert in programming in general. I hope that helps 🙂
Derek
Hello Derek,
Thank you very much for uploading this tutorial.
I have one question about the code. In LESSONSIXTEEN.JAVA, line 53, System.out.println(superCar.toString()); why don’t you use superCar.getClasss().toString()?
You’re very welcome 🙂 I just used the code that I did to explain how toString works.
From where to download eclipse for programming of java? and which version.
I made a tutorial for that called Install Eclipse for Java. I hope it helps 🙂
Hi Derek,
I’m trying to understand the syntax for the following statement:
superCar.getClass().getName()
Is such a statement does it say that there is a function (method) as part of the object (superCar) and inside the getClass() method there is another method defined as getName()?
Thanks for the explanation.
jp
Hi
superCar.getClass().getName() is getting the name of the class for the object superCar
excelent tuto, gracias Derek
Thank you 🙂