As was suggested read the instructions that come with the version of Xcode you're wishing to install.
Step-by-Step Instructions
Note: By default, all versions of Xcode (and iPhone SDK) install in /Developer with previous versions automatically upgraded. If you want to keep a previously installed version of Xcode, you must either do a "Custom Install" and specify a new <Xcode> directory name (e.g. /Xcode3.2) or you must move the pre-existing /Developer directory to a new name before you install Xcode 3.2. See step 5 below.
1. Boot into a partition with the Mac OS X v10.6.0 or later installed.
2. Download the Xcode and iPhone SDK software. 3. Double-click on the Installer package.
4. Follow the instructions in the Installer.
5. To install Xcode in a directory other than the default /Developer, you must specify a new <Xcode> directory name on the "Custom Install" pane
- Select the folder icon under "Location" next to the "Essentials" package.
- Select "Other..." at the top of the pop-up.
- Navigate to the location for the new <Xcode> folder. Select "New Folder".
- Enter a folder name in the "New Folder" window; Select "Create".
- Finally, select "Choose" in the "Install Xcode Tools" pane.
6. If you need to install Mac OS X 10.4 support you must select "Customize", and check that package on the "Custom Install" panel.
7. Authenticate as the administrative user. The first user you create when setting up Mac OS X has administrator privileges by default.
Once you have installed the Xcode developer tools, you can access the documentation by launching Xcode and choosing any of the items in the Help menu. Developer applications such as Xcode, Instruments, and Interface Builder are installed in <Xcode>/Applications.
Uninstalling Xcode Developer Tools
To uninstall Xcode developer tools on the boot volume along with the <Xcode> directory, from a Terminal window type:
$ sudo <Xcode>/Library/uninstall-devtools --mode=all
To remove the underlying developer content on the boot volume, but leave the <Xcode> directory and supporting files untouched, from a Terminal window type:
$ sudo <Xcode>/Library/uninstall-devtools -- mode=systemsupport
To just remove the UNIX development support on the boot volume, but leave the <Xcode> directory and supporting files untouched, from a Terminal window type:
$ sudo <Xcode>/Library/uninstall-devtools --mode=unixdev
Finally, to just uninstall the <Xcode> directory you can simply drag it to the trash, or from a Terminal window type:
$ sudo <Xcode>/Library/uninstall-devtools --mode=xcodedir
NOTE: The uninstaller that ships with previous versions of the Xcode developer tools will not clean everything off of your system properly. You should use the one installed with the Xcode 3.2 developer tools.