Hello all, i was just introduced to objects and am trying to construct a program using get/set. i just want to set the user read variable and read it back. I have it almost figured out but for some reason it will not display anything for the value. heres what i have.
object
public class CircleObj {
public void Constructor(){
System.out.print("I work");
}
private String VarX;
public void setVarX( String X ){
X = VarX;}
public String getVarX(){
return VarX;}
public void displayMessage(){
System.out.printf("The Value for X is: ", VarX);
}
}
main program
import java.util.Scanner;
public class UseCircles {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
CircleObj myCircleObj = new CircleObj();
System.out.println ("Please enter value for X:" );
String theX = input.nextLine();
myCircleObj.setVarX( theX );
myCircleObj.displayMessage();
}
}
this is my output:
Please enter value for X:
9
The Value for X is:
_____________________
how come that 9 wont show up??