Experience in Minecraft
Experience points (or XP) are awarded for:
You get experience points if you kill a mob, or if you damage a mob before it dies (perhaps ifyou hit it with a sword and it falls off a cliff).
Most hostile mobs reward you with 5 XP, passive mobs, on average, 2. Venture into the Nether and fight Blazes for 10 XP each.
One way to get large amounts of XP is to build an XP grinder.
You get XP from mining ores any of the ores that drop items rather than blocks: Coal, Redstone, Diamond, Emerald, Lapis Lazuli and Nether Quartz.
Smelting and cooking
You get XP when you empty your furnace after cooking or smelting something. Making large quantities of glass or smooth stone for your building projects is a great way to amass lots of XP. Bake wood into charcoal to fuel your furnaces, as that generates XP too.
Fishing and Farming
Fishing and breeding animals gives experience points. And of course, you get more XP when you cook meat or fish.
Villager priests (the dudes in the purple robes) will sometimes sell you bottle o'enchanting that will give you 3–11 XP when you break it on the ground. Not worth the emeralds, in my opinion.
Collecting a certain number of XP increases your experience level.
Levels 1–16 require 17 XP each. After that, they start to get more expensive, with each level needing more XP than the one before it.
This means that it only makes sense to allow your experience level to increase above 16 if you're saving up levels for an expensive enchantment.