There are two parts to the hunger problem in NetHack: gaining nutrition and reducing nutrition loss.
Under normal conditions, each turn, you lose one point of nutrition. You start with 900 nutrition, and start feeling hungry when you drop below 150. At 0, you'll faint. Starving to death happens at a negative value based on your constitution.
Nethack is a very complex game, so there are exceptions to most of the guidelines below, and other, more obscure ways of sustaining yourself, but these general principles are good guidelines.
Comestibles. The most straightforward way to gain nutrition is to eat comestibles (labeled as
% - food, meat and corpses). The amount of nutrition you get depends on what you eat. Early on in the game is often the riskiest time; you may not start with much food. At this stage, it's normal to eat as many fresh, safe corpses as you can get your hands on. If you make it that far, there is guaranteed food in the Sokoban levels, which are accessed somewhere between levels 6-10.
Praying. Praying while weak will restore your nutrition, but safe use depends on your current prayer timeout. Also, using up your favour with your god could backfire if you have a sudden unforseen need (e.g. you have gained a fatal illness like food poisoning, or are being turned to stone).
Convert boulders to food. As theist points out, you can convert boulders to huge chunks of meat if you have the stone to flesh spell. These are hugely nutritious (2000 points).
Reducing nutrition loss
Wear a ring of slow digestion. This is a great item, if you can find one. It changes your rate of nutrition consumption to 5% of your normal rate (giving you twenty times as long to find food). As Grace Note points out in the comment below, this is because you are only paying the nutrition cost of the ring - your standard rate of consumption is halted.
Take off your rings. In general, you lose one nutrition every twenty turns for each ring or amulet you wear. Rings of regeneration are particularly pernicious; if you're wearing one, you'll lose a point every other turn.
Drop your stuff. If you're Stressed or heavier, you lose a point every other turn.
Don't cast spells. Spellcasting makes you hungry (unless you're a wizard with high Intelligence).