Private method in groovy is not private

后端 未结 5 2081
慢半拍i
慢半拍i 2020-12-18 19:12
class A {
    private def sayHello() {
       println \"Anish\"
    } 
 }

 def a_obj = new A()
 a_obj.sayHello()

output : Anish

5条回答
  •  眼角桃花
    2020-12-18 19:19

    Searching for [groovy] private reveals:

    groovy call private method in Java super class

    What does 'private' mean in Groovy?

    How to define private getter method in Groovy Bean?

    It's not clear if it is a bug or by design, but it is going to get looked at again in Groovy 2.0

提交回复
热议问题