package com.codegym.task.task02.task0204;
/*
Family relations
*/
public class Solution {
public static void main(String[] args) {
//write your code here
Man man = new Man();
Woman woman = new Woman();
woman.husband=Man;
Man.wife=Woman;
}
public static class Man {
public int age;
public int height;
public Woman wife;
}
public static class Woman {
public int age;
public int height;
public Man husband;
}
}
Chris Taylor
Level 2
What am I doing wrong? I can't see any issue with the code
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Goff
8 October 2019, 21:43
woman.husband=Man; Man.wife=Woman;
Man and Woman are classes. First you create an object man from class Man and an object woman from class Woman. That's correct. Then you have to point woman.husband to object man. It is not possible to point it to the hole class Man. Java is case sensitive. Woman can be married with one particular man, but not with description, how a man looks like ))
0