Observations of the coronae of the Sun and of solar-like stars provide complementary information to advance our understanding of stellar magnetic activity, and of the processes leading to the heating of their outer atmospheres. While solar observations allow us to study the corona at high spatial and temporal resolution, the study of stellar coronae allows us to probe stellar activity over a wide range of ages and stellar parameters. Stellar studies therefore provide us with additional tools for understanding coronal heating processes, as well as the long-term evolution of solar X-ray activity. We discuss how recent studies of stellar magnetic fields and coronae contribute to our understanding of the phenomenon of activity and coronal heating in late-type stars.