There's the classic argument of which comes first, the chicken or the egg? In this case, it's which comes first: 401(k) or debt.
Many adults and investors are divided on the subject of new college graduates saving for retirement. Some feel these young adults shouldn't invest a dime until they pay off their student loans. Others feel equally strongly that they should contribute at least enough to their workplace 401(k) retirement plans to earn any matching contributions their employers provide. It is a serious dilemma and worth a closer look.

Debt is the single biggest financial concern for young investors, and college costs are the single biggest source of that debt, according to Spectrem Group, an affluent- and retirement-market consultancy.

At the same time, many American workers aren't saving enough for retirement. Nearly 30% of them aren't even contributing enough to their 401(k)s to receive the full employer match—widely considered to be "free money"—according to human-resources consulting firm Aon Hewitt. The problem is even worse among the youngest workers—age 20 to 29—42% of whom fail to contribute to the full extent of their employer match.

The Financial Industry Regulatory Authority, which monitors securities firms, found the situation so concerning that it issued an investor alert on the topic, urging all American workers to take full advantage of their employers' 401(k) matching contributions.

But should young adults with student debt follow suit?

I asked San Diego financial adviser Deborah Fox to run some numbers. Ms. Fox is founder of Essential Planning Services, a wealth-management firm, and Fox College Funding, a college-planning advisory firm for higher-income families who don't qualify for need-based financial aid.

What she found: It somewhat depends on the size of the employer match, but in general you don't want to leave any of it on the table.

Say you are a recent graduate who borrowed the maximum amount of Stafford loans available during college—$27,000. (These are federal, fixed-rate student loans for undergraduates and graduate students.) Your loan balance would now approach $33,000—including interest accrued during school.

Say you also have a job with a 401(k) plan, you earn $50,000 a year, and your employer matches 50% of your 401(k) contributions up to 6% of pay, a common formula. Your choice: Contribute $3,000 a year to the 401(k) to get the maximum employer match, or use that $3,000 a year to pay down additional loan principal on top of your regular student loan payment of $4,500 a year.

In the first scenario, your loan would be paid off in 10 years, assuming a standard repayment plan. In the second scenario, your loan would be paid off in just over five years, after which your loan-payment amounts would be redirected to your 401(k).

By qualifying for the employer match in each of the 10 years and not prepaying the loan, you'd be ahead by more than $6,000, Ms. Fox found. This calculation assumes an annual investment return of 6.8% on the 401(k) account (which is equal to the loan interest rate), and takes into account the effect of tax deductions for the loan payments and 401(k) contributions.

In fact, as long as your 401(k) earned more than 3.5% annually, Ms. Fox says, you'd be better off snagging the match than prepaying the loan.

With a more generous match of 100% of employee contributions up to 5% of pay, you'd come out slightly ahead even if you earned nothing on the 401(k) account. (Note: Many employers automatically enroll new employees at only 3% of pay, so if you want to contribute more you may have to say so. The maximum contribution allowed by the Internal Revenue Service for this year is $17,000.)

Bottom line: Do what you can to grab as much of your employer's match as possible, including finding other sources of money to repay your student loans. Think creatively. Signing bonuses or relocation funds could be used to knock down debt, as could future bonuses or incentive pay, says Ms. Fox.

Ditto for graduation gifts. Randi Boven of Fort Lauderdale got an unexpected tax refund this year due to education credits for two sons in college. She divided the money—around $3,000—and put it away to give to each of them upon graduation.

The oldest, an aspiring broadcast journalist, will graduate in December. He doesn't know about the gift yet, but Ms. Boven is confident he'll use it wisely, perhaps to pay down some student debt so he can get on with the business of saving for retirement.

"One thing is for sure," says Ms. Boven, "my children know I am not going to support them."