Accessing the containing class of an inner class in Java

后端 未结 3 1036
时光取名叫无心
时光取名叫无心 2021-01-17 09:12

This is what I\'m doing now. Is there a better way to access the super class?

public class SearchWidget {
    private void addWishlistButton() {
        fina         


        
3条回答
  •  情深已故
    2021-01-17 09:45

    You can write the name of the outer class and then .this. So:

    workWithWidget(SearchWidget.this);
    

提交回复
热议问题