Originally posted by Joig: How i can set a variable
Depends on where you want to set it FROM. When you are inside the code of a class, and the variable is a class member, you can just set it as shown above. If you are in another class and you want to set the value of a member variable for an instance that you hold a reference to you can use: myVarHoldingYourClass.IamTheKing = 27; Well, this is true if the variable is accessible. If it is private (like it probably SHOULD be) then you have to rely on the class having methods to set the value. The class holding the private variable would probable have a method named setIamTheKing(int i); and you would call it using myVarHoldingYourClass.setIamTheKing(27); Now if the variable happens to be static then it does not relate to any particular instance of the class, so you can just use the ClassName to get at the public variable: YourClass.IamTheKing = 27; Do we need to continue and talk about local variables, and using this to refer to the instance that we are in?
"JavaRanch, where the deer and the Certified play" - David O'Meara