You can't develop Apex in your Salesforce production org. Live users accessing the system while you're developing can destabilize your data or corrupt your application. Instead, do all your development work in either a sandbox or a Developer Edition org.
If you aren't already a member of the developer community, go to http://developer.salesforce.com/signup and follow the instructions to sign up for a Developer Edition account. A Developer Edition account gives you access to a free Developer Edition org. Even if you already have a Professional, Enterprise, Unlimited, or Performance Edition org and a sandbox for creating Apex, we strongly recommend that you take advantage of the resources available in the developer community.
To create a sandbox org:
If you don’t see a sandbox option or need licenses for more, contact Salesforce to order sandboxes for your org.
If you reduce the number of sandboxes you purchase, you are required to match the number of your sandboxes to the number you purchased. For example, if you have two Full sandboxes but purchased only one, you can’t create a Full sandbox. Instead, convert a Full sandbox to a smaller one, such as a Developer Pro or Developer sandbox, depending on which types you have available.