Let C be the capacitance of the capacitors and Q be the charge developed in the charged capacitor. The energy stored in it is given by
Now, when this capacitor is connected to another similar capacitor, charge will flow from the charged capacitor to the uncharged capacitor till they develop a common potential V, given by
Energy stored in each capacitor