Energy in a capacitor is independent of the manner in which the charge configuration of the capacitor is built up.