That's the wrong way to think about it. Credit isn't something you just get when you need it. You have to build it so it's available when you want to use it, this takes time.
Through high school and college I had a credit card that started out with a $150 limit and grew to around $800 or so. I used it for books and other small stuff. By the time I bought my first home at 21 my credit score was in the mid-high 700's. By the time I was in my mid-20's it was around 800.
I'd have had a harder time and higher rates if I hadn't established my credit early.