Just plain "loitering"--that is, lingering in a public place with no apparent purpose--is not a crime in California. However, loitering with the intent to commit a crime and/or in certain places can be a crime.
For example, it is a crime to loiter at a school or other public place where children congregate, provided that you do so with the intent to commit a crime if the opportunity arises. People are often charged under this law (Penal Code 653b PC) when prosecutors allege that they intended to sell drugs to minors or engage in sex crimes involving minors.
Another important California loitering crime is loitering with intent to commit prostitution. This crime is exactly what it sounds like and allows police to arrest people they suspect intend to commit prostitution.
California law also makes it a crime to loiter to solicit the purchase of alcohol. Penal Code 303a charges are brought against people--often minors--who loiter outside bars or restaurants intending to ask people to buy alcoholic drinks for them.