//******************************************** public class Main { public static void main(String[] args) { // super = keyword refers to the superclass (parent) of an object // very similar to the "this" keyword Hero hero1 = new Hero("Batman",42,"$$$"); Hero hero2 = new Hero("Superman",43,"everything"); System.out.println(hero2.toString()); } } //******************************************** public class Person { String name; int age; Person(String name,int age){ this.name = name; this.age = age; } public String toString() { return this.name + " " + this.age + " "; } }//******************************************** public class Hero extends Person{ String power; Hero(String name,int age,String power){ super(name,age); this.power = power; } public String toString() { return super.toString()+this.power; } }//********************************************
This is the best RU-vid Channel for teaching how to Code on RU-vid ! Keep going and you will surely reach the 1 Million soon ! Thank you for the great way in explaining !
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
Awesome video. I'm new to programming and learning JAVA atm. Would surely enroll in one of your courses if you had them because all the subjects i struggle with in my textbook are always clear to me after one of your video's!
just put hero2, i use intellij and it says that it's a redundant string call and it's useless, toString means to convert the memory value/data into a readable string, which was already done in the other classes
great stuff!! I've gone through a year and a half in college, we never had Java, but after I switched to another college (years later), they're having Java there and it's been a pain because of the virtual environment. maybe my plugin in the IDE can't handle saving the file multiple times to adjust something because it always tells me it couldn't delete one of the temp files, and in the terminal it works the way it did before the alterations I've done so it's like I'm running the older version of that file. then I restart the computer to make the temp files forcibly get removed whenever I can't build the project and it works, all of the alterations are applied.
Superman is your favorite hero right?? Yeah I find BAtman lame too ! Thats why you printed 'hero2' attributes when you also had 'hero1' ! 😉😄 NIce turorial bdw..... So far loving the simplicity of videos.
Hello Bro Code , in your video I see a lot of samples in "package explorer". From were do you get these samples? I would like to get these samples too. any help would be very nice.
When the class is an extension of the parent class, if an object is instantiated within the child class does that mean the variables/objects that were extended are separate from the variables/objects of the original parent class? (Sorry if that was worded poorly as I'm still new to this)
Is it because we cannot make objects on superclasses in java, so the hero-class has to extend the "toString" methode of the person-class? would that be called overriding?
Hello Bro Code, in your video I can see a lot of samples in "Package Explorer" ,from were did you get these samples? I would like to get these samples too. can you give me these samples or give me the internet link to these samples? any help would be very appreciated