Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid inner class' name collision?

If I have a class A and a class B which is A's inner class. Also I have another class B. It's not in A.

class A {
    ...
    class B {
        ...
    }
    ...
}

class B {
    ...
}

How do I make an instance of outer B in A?

class A {
    B name = new B();
}

will get an instance of inner B.

like image 339
Lai Yu-Hsuan Avatar asked Dec 08 '25 23:12

Lai Yu-Hsuan


1 Answers

Specify the fully-qualified name of the external B. If B is in package com.acme, then say com.acme.B name = new com.acme.B();.

like image 157
Chris Jester-Young Avatar answered Dec 11 '25 11:12

Chris Jester-Young



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!