public class Solution {
public static void main(String[] args) {
Man man = new Man();
Woman woman = new Woman();
man.wife = Woman;
Woman.husband = Man;
}
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;
}
}
whats the wrong with my code?
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
sneha
25 February 2019, 10:28
it should not refer to the class Woman and Man but to the object woman and man
man.wife=woman;
woman.husband=man;
0
Jeff Lamb
18 February 2019, 04:11
Agreed with all three comments below. It should be the object man, not the Class Man.
0
Ratan Ganeshie
5 November 2018, 15:13
This wrong capital W for woman
M for man
man.wife=woman;
woman.husband = man;
0
SIVAKAMI
29 October 2018, 00:11
As per Khurram stated, man.wife = woman and woman.husband = man. It should not refer to the class Woman and Man but to the object woman and man.
0
Khurram
27 October 2018, 13:37
man.wife and woman.husband should store references to the object man and woman not the classes Man and Woman
0