I have created two objects of each type. But, the compiler is showing an error (Be sure that you are creating 2 Man objects.).
What's wrong here. Someone, please help. with an explanation.
package com.codegym.task.task05.task0526;
/*
Man and woman
*/
public class Solution {
public static void main(String[] args) {
//write your code here
Man man1 = new Man();
Man man2 = new Man();
Woman woman1 = new Woman();
Woman woman2 = new Woman();
System.out.println(man1.name+" "+man1.age+" "+man1.address);
System.out.println(man2.name+" "+man2.age+" "+man2.address);
System.out.println(woman1.name+" "+woman1.age+" "+woman1.address);
System.out.println(woman2.name+" "+woman2.age+" "+woman2.address);
}
public static class Man{
String name;
int age;
String address;
public Man()
{
this("man", 19, "india");
}
public Man(String name,int age,String address)
{
this.name = name;
this.address = address;
this.age = age;
}
}
public static class Woman{
String name;
int age;
String address;
public Woman()
{
this("Woman", 19, "India");
}
public Woman(String name,int age,String address)
{
this.name = name;
this.address = address;
this.age = age;
}
}
//write your code here
}