I have a superclass named Message with the field String msgType and a sub-class named ConnectMessage that extends it, which contains the field String pos_X.
The constructor of ConnectMessage is:
public ConnectMessage(String msgType, String x){
    super(msgType);
    this.pos_X = x;}
Inside the main thread i call: clientMessage = Message.fromString(inputString);
where fromString creates a ConnectMessage instance like this:
ConnectMessage cm = new ConnectMessage(str1, str2);
return cm;
But when in the main thread i call s = clientMessage.pos_X i get a compiler error, saying that there is no variable pos_X in class Message. How does inheritance work here and how can i fix that, so that the statement clientMessage.pos_X will mean pos_X defined in class ConnectMessage?
 
     
     
     
     
     
     
     
    