Skip to content

Diferencia/función entre Private y Public en Java #113

Discussion options

You must be logged in to vote

Si no me equivoco, y siguiendo el ejemplo que pusiste, lo que haría el private es que solo puedas llamar a procesarComida dentro la clase. Osea que literalmente el código .procesarComida esté dentro de:

class Golondrina {
...
}

Si querés hacer:

class SantuarioDeAves {
    unaGolondrina = new Golodrina();
    unaGolondrina.procesarComida();
}

no debería dejarte ya que ".procesarComida()" no está dentro de class Golondrina { ... }

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gastonprieto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #10 on April 09, 2021 22:50.