I learned how to call the function of another contract in solidity. However, I can not find any approach to access to the state variables as follow attempt, so how to do it in solidity ^0.8.17?
contract A {
uint public x = 3;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "./A.sol";
contract B {
A public contractA ;
function getAcontractState() public{
contractA = new A();
uint y = contractA.x; // error is here.
}
}