Can someone help me find my errors?
Code:
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;
}
}
Still can't figure this out.
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Jay
10 December 2019, 06:04
Hi Shawn,
You are assigning the default class constructor reference instead of passing the object reference of that class.
Change the below lines to reference the object of the class.
Below is the correct way of referencing and assigning object or instance of a class :
+3