I'm still learning about investing and want to know if I should invest in 401(k) or is it better to invest by yourself in stocks? Or do both? Can you pick your own stocks with 401(k)?
The answer, of course, is "it depends". It depends on your income & tax situation, the investment options and employer matches of your particular 401k, and your personal goals.
The key point here is that 401k and IRA accounts* are intended as long-term retirement savings plans. As such, they have tax advantages (investments are before tax, and taxes are only due when money is taken out of them) and possible employer matches. That means that you are probably getting a bunch of "free money" that you wouldn't get with regular investments. The downside of this is that you will generally pay a fairly large penalty if you take money out before retirement age (59 1/2, IIRC).
With personal investing, the situation is reversed. Any money you invest is after tax, and if you do trading in your account, you will be paying tax on capital gains & dividends every year. OTOH, the money is yours: you can take it out at any time (but have to pay capital gains tax) and use it for any purpose you like.
My own opinion (and what I have actually done) is that if you have sufficient income, put as much as you can get the employer match on into a 401k (if you're an employee), or as much as is tax deductible into an IRA. Then invest in mutual funds on your own.
*I'm not discussing Roth-style accounts here.
A 401(k) is a retirement account through your employer. Some 401(k) programs also include a Roth option. There are similar program to a 401(k) if your employer is the Federal government (TSP) or public education (403(b)).
Inside the 401(k) you generally have a list of mutual funds to invest in. Some are stock funds, some a bond funds. Some of these funds focus on US based investments, some are international. Some can even invest in real estate. Some funds are a blend of these different options.
In some 401(k) programs you can buy company stock. Of course that option only exists if the employer has shares, not all do.
In some programs you can invest in individual stocks.
You need to get the plan information from your employer, to see the exact options they offer.
Many people pick a 401(k) or IRA because of tax issues, or in the case of the 401(k) the employer may match some of their investment.
My recommendation, since you are just starting out, would be to put 100% of your contributions into an S&P 500 index fund.
This works well for portfolios that are small (< 100K), if you are young (<30 years old), and have a tolerance for risk. Also this assumes that your company 401K has a low cost (< 1% per year fees) S&P 500 index fund.
Eventually you will want to move to a bit more sophisticated asset allocation model, but for the conditions described above, doing 100% S&P 500 index fund works just fine.
The key thing is to just get started. Many new investors allow the fear of making a sub-optimal decision preclude them from investing. Don't let that be you. Its much better to have your money make some money then none at all.