Originally Posted by
nikki101
Basically I want to access variables of the constructor to do some computations and print out the variables of the constructor.
Assuming class one creates an object of class two, and then attempts to get values from class two to print during the life of class one? I take "variables of the constructor" to mean "variables declared in the constructor" , by looking at the code for class two:
Originally Posted by
nikki101
class two
//default constructor
two
{
String variable 1 ="";
String variable 2 ="";
String variable 3 ="";
}
get() and set() for the variables in the constructor
It is not possible like that. The scope of those variables is gone once the constructor returns, and the constructor does not return values. Either use those variables in a larger scope (class or instance variables) or the constructor will have to send those values out during construction through method calls.
On the same token, get() and set() would have no access to the values of variables declared in the constructor. So I am confused, did you mean to declare those Strings as instance variables and initialize them in the constructor? The pseudo code does not quite fill in all of the blanks.
Can you explain more what you are trying to do? ..There are ways to do what you want to do, the best way depends on exactly what you are trying to do.