Particle-in-cell simulation of free-electon lasers has contributed significantly to understanding its physics, especially in the non-linear and multidimensional regimes where analytic theory is rather difficult to formulate. The basic techniques of plasma simulation and the one- and two-dimensional codes used in the simulation of free-electron lasers are discussed in detail. Important results obtained from simulation are presented: It has been found that waves propagating obliquely with respect to the electron beam are always unstable with appreciable growth rates and, therefore, the efficiency of generation of the on-axis high-frequency electromagnetic wave can be severely degraded. Furthermore, electromagnetic waves with group velocities opposite to the direction of electron beam propagation can be absolutely unstable. Complete disruption of the electron beam and laser oscillation due to the onset of the absolute instability have been observed in simulations. Moreover, computer simulation also shows that the absolute instability can be avoided if the parameters of the free-electron laser satisfy certain constraints. The dynamics of nonlinear saturation and the potential efficiency of energy extraction are presented in detail.