As a consequence of the first law of thermodynamics, U is a state function. That means that at a specific state the material inside the container has a unique value of U. If the variables which define the state, e.g. volume V, pressure P, temperature T or others, change on some closed path and the initial values are reached again, U will also attain its specific value. Such U or any other state function is specific set of state variables. The path how this state was reached is irrelevant for the value of U. Mathematically U and any state function has a total differential.