Often, electricians will nail boxes for light switches and outlets on the side of a stud. This can help you find the general location of a stud in the center of a wall. Note that it's not immediately clear on which side of the box you'll find the stud. For this, you need the stud finder.
It's important to know that not all electrical boxes are nailed onto studs. Some boxes are set directly in the drywall.

