if i have a constructor like so:
public Constructor (int a, int b){
int c = a;
int d = b;
}
How can i then use variable c and d in a method within the same class as the constructor because trying to use just the variables name in the method doesn’t seem to work?
In fact your code will not compile –
int c = int ais not valid.I assume that you meant: –
int c = a;.You can’t because you have declared them as local variables whose scope ends when the constructor ends execution.
You should declare them as instance variables.