This seems like a fairly easy question, but I'm having a hard time finding a definitive answer. Currently, I have a public class, and in the constructor I'm defining a variable like this:
private String password = "abcd123456";
Then I have a method like this:
public String getValue(String inputValue)
{
String returnValue = encryptor.decrypt(inputValue, password);
return returnValue;
}
The class is defined as public as well. When I reference this class from a form, I'm doing this:
ValueGetter vg = new ValueGetter();
String decryptedValue = vg.getValue("xfr3sf342d#2");
I would think that by defining password as private, only that class would be able to see it. However, if I am in debug, after I hover the mouse over the "vg" variable to view the contents of the object, I can see the password plain and clear. Is there a way to make the variable password only known to that class, but still defined in the constructor? There will be several methods within the class using that variable, which can be called from external forms, so I'd rather have it in the constructor than having to re-define the variable in each method.
Thanks in advance!
I used password as the most obvious reason why you would want to hide a variable, but in actuality, I don't want someone to write an interface to a class, and get a bunch of garbage that doesn't mean anything to them back out of the object. So I might have a class called beach, and a method called getBeachBall. It returns me a beach ball that is orange, inflated with xx pounds of air, etc. In the class that contains the method, I have another variable called TableShape. This color would always be white, and non-changeable. I was just wondering if tableShape could be masked, since only the Beach class would use it for something. The original caller would never know anything about the tableColor variable.