r/javahelp • • Jun 08 '16

Need help with question

class A{
  static class B{}
  static class C{ B b;
    C(B b){this.b=b;}
    int foo(){return 42;}
  }
}
public class Exercise{

  public static void main(String [] arg){
    assert ([???].foo()==42);
  }
}

Gotta full in the ???

0 Upvotes

7 comments sorted by

4

u/deltageek Extreme Brewer Jun 08 '16

What have you tried?

4

u/desrtfx Out of Coffee error - System halted Jun 08 '16

/r/javahelp does not work like this.

Please, read and follow the Posting guidelines

We will not do your homework.

2

u/RhoOfFeh Jun 08 '16

First hint: What in the code has a thing called foo()?

1

u/Protagoras Jun 08 '16

I'm sorry there exists no valid answer. You cannot create a valid Java statement by substitution of the "???" substring.

5

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jun 08 '16

I think it's obvious he meant [???]. Still not going to do his homework though.

3

u/Protagoras Jun 08 '16

I reserve the right to be a pedantic a**hole when asked to do some random persons homework. Especially if they don't even ask their homework question properly.

3

u/nutrecht Lead Software Engineer / EU / 20+ YXP Jun 08 '16

Can't disagree on that ;)