What's the difference between public and private in java programming?

What’s the difference between public and private in java programming?
Also,
what’s is the meaning of this: public int speed;

Thanks =)

One Response to “What's the difference between public and private in java programming?”

  • jaffamol:

    Public means it is accessible to classes from outside itself.
    Private means it is only accessible from within the class itself.

    public int speed;

    Would declare a public integer variable called speed.

Leave a Reply