That's all well and good, but I think it's also important for a writer to write out of their regular knowledge and comfort zone.
Because if you don't stray out of your norm your books all start sounding the same.
So be bold and be brave. Write an experience you have no idea how it feels like. Write a character that's the complete opposite of you. Write in a location you've never been in. It grows you as a writer.
One of the young writers I've critiqued said, "I'm not very good at imagining myself in those kinds of situations." Part of being a writing is using that imagination that never left you from childhood. As a kid, I played so many pretend games in all kinds of imaginary settings. I would even come up with story lines for them and for my Fashion Pollies and Barbies. So lets harness some of that pulling-out-of-nothing imagination we had as kids.
1.) Research - This is a big way to tap into settings, situations and such to get a good idea of it before writing. Use Google (with caution), your local library or even ask people you know. If you need to research police protocol and you know a policeman, awesome, you've got some great hands on research. :) You can look up pictures of settings and characters and keep them in a file on your computer or on Pinterest.
2.) Facts from School - Also if you're in school and you learn something cool, write it down! One thing that made school more for me was doing that. :) I took Anatomy and Physiology in my senior year, and I took so many notes for my sci-fi series, Subsapien. It made the subject way more fun. To create varied characters, study people and characters in other books. Everyone is different so try to pick out the differences and make sure each of your characters are unique. :)
3.) Picturing Yourself - Sometimes there are situations where you have trouble emotionally connecting with the character or ones that hopefully no one has been in. One way of using it is to connect a situation to something in your life. Like (hopefully) we've never had a bad guy kidnap your sibling, but how do we get the drama into that situation? Try relating that sibling to one of yours or a little kid that you like. If you write in emotion, the readers will feel it.
Write what you know, but don't forget to branch out and write what you don't. Try new things and let your characters grow. :)
Do you have any questions about writing what you don't know? Have you ever researched something for your book you knew nothing about?
You may also like:
From Lemons to Book Experiences
Tone Down But Don't Water Down
Five Tips on Writing a Good Main Character
How To Write A 3D Villain Part 1
How To Write A 3D Villain Part 2