Springs
Potential energy can also be stored in a spring, but to discuss that we first need to talk about the force a spring can exert. For our purposes we are going to imagine an ideal spring which can be compressed or expanded, as shown here. When a spring is relaxed, it has a natural (or equilibrium) length which we'll call $L_0$. As the spring is stretched, the spring fights back, pulling on whatever is stretching it with a force that increases as the spring gets longer. If L is the total length of the spring when stretched, then the force the spring exerts is
In the figure a truck is stretching the spring, which means the truck feels a force to the left equal to $F=k(L-L_0)$. Since the truck is moving to the right, the work done on the truck is negative: the spring steals energy from the truck. This energy isn't lost, however, such as with kinetic friction; rather, the energy is stored in the spring as potential energy, and it will be released once the spring is allowed to relax. The total potential energy stored in the spring is equal to the total work Fd the spring would do on a truck that stretched it from its initial length $L_0$ to its final length $L.$
The same argument can be made if the spring is compressed; in that case $L-L_0$ is negative, but because we square that quantity in the energy, a compressed spring also stores potential energy. (In real springs, the spring constant may be different for expansion and compression, especially in a spring where the coils are closely packed together as shown on the left.)