To access a variable in a class in Java, is it better to return its value via a method, or just acces it via myClass.variable? -


i think title says all. maybe should ask: ever bad not use method return variable, or value? example 2-d point class x , y variable.

is there wrong using mypoint.x x variable of mypoint opposed mypoint.xvalue(), returns mypoint.x?

you should make code, encapsulated, use setters , getters.

set , methods in java?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -