13

Why a private method is not there when i use javap classname on console after compiling that java file?

class A
{
    private void one(){}
    public void two(){}
    protected void three(){}
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
manish gupta
  • 131
  • 4
  • In general you'll get more helpful answers if you're able to explain a little more context about why it matters. In this case the answer is essentially "because it doesn't". If you provide more information on the wider problem you're trying to solve that's hampered by not listing the private methods you're likely to get a bit more help in solving the original problem. – EdC Sep 14 '12 at 10:57

1 Answers1

23

Private methods are not displayed by default, you need to use:

javap -private A
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • yes its working but is there any particular reason for doing so? – manish gupta Sep 08 '12 at 11:04
  • Probably because the vast majority of use cases only require `public` & `protected` methods to be shown and therefore making `private` methods optional make sense :) – Reimeus Jun 07 '14 at 17:17
  • @Reimeus This answer worked for me! Looks like OP forgot about you though :p – flakes Nov 01 '16 at 20:43