Haven't touched java in about 5 years, been in the perl world.
What i am trying to do is use one method for my setter and my getter in a class. Here is how I *think* it should look.
<pre>
----
protected int test_var ;
public int test_var(int new_test_var) {
if(!new_test_var){
test_var = new_test_var;
}
return test_var ;
}
----
</pre>
Now obviously this doesn't work, the int type in java doesn't return a boolean. Is there an isInt style call I can use to see if an int was passed into the function.
This is so Java 101, thanks for any solutions.
What i am trying to do is use one method for my setter and my getter in a class. Here is how I *think* it should look.
<pre>
----
protected int test_var ;
public int test_var(int new_test_var) {
if(!new_test_var){
test_var = new_test_var;
}
return test_var ;
}
----
</pre>
Now obviously this doesn't work, the int type in java doesn't return a boolean. Is there an isInt style call I can use to see if an int was passed into the function.
This is so Java 101, thanks for any solutions.