i will never understand why would someone use 3 of the same name for different things.. Why wouldnt you name the class gadgets, object laptop, and constructor something else
class Person { String? name; String? planet; Person(){ this.planet = "Earth"; } } void main() { Person p1 = Person(); p1.name = "Raj"; //p1.planet = "Saturn"; print("The person named ${p1.name} is from the planet ${p1.planet}"); Person p2 = Person(); p2.name = "Ram"; print("The person named ${p2.name} is also from the planet ${p2.planet}"); }
Thank you for the simple explanation. Wish you all the best!! 👍
Good teacher ever
Man you're awesome!
Thanx
brooooo, you are good, you may not see this comment but thanks alot.
class person {
// PROPERTIES
String? name;
String? planet;
// DEFAULT CONSTRUCTOR
person () {
this.planet = 'EARTH';
}
main () {
person p =person ();
p.name = 'sakib kadri';
print (p.name);
print(p.planet);
}
OUTPUT IS:
SAKIB KADRI
EARTH ->YAHA PAR EARTH EK DEFAULT CONSTRUCTOR HE.
🥰🥰🥰
Happy learning.
@@darttutorial Yes sir watching regularly step by step
i will never understand why would someone use 3 of the same name for different things.. Why wouldnt you name the class gadgets, object laptop, and constructor something else
The class and constructor name must be the same ,thats the rule but u can use differentt name for the object😊
class Person {
String? name;
String? planet;
Person(){
this.planet = "Earth";
}
}
void main() {
Person p1 = Person();
p1.name = "Raj";
//p1.planet = "Saturn";
print("The person named ${p1.name} is from the planet ${p1.planet}");
Person p2 = Person();
p2.name = "Ram";
print("The person named ${p2.name} is also from the planet ${p2.planet}");
}