package pl.codegym.task.task02.task0204;
/*
Family relations
*/
public class Solution {
public static void main(String[] args) {
//tutaj wpisz swój kod
Man man = new Man();
man.wife = new woman(){
Woman woman = new Woman();
woman.husband = new Man(){ //here is something incorret
}
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;
}
}
what is wrong with comilation?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Anthony Chalk
12 November 2019, 10:52
Since you've created man and woman objects try instead woman.husband = man;
This will reference the Man you've already created as opposed to creating a new one.
0
Patryk Zet
12 November 2019, 23:10
Unfortunately, It stil not working :(
Woman woman = new Woman();
woman.husband = man ;
0