Although there exist a lot of approaches to solve constrained optimization problem, few of them makes use of the knowledge obtained in the searching process. In the paper, a new algorithm called nearest neighbor evolutionary algorithm (NNE) is proposed to solve the constrained optimization problem. NNE not only performs global search and local search in the searching process, but also considers the knowledge obtained in the searching process. NNE also avail itself of the elitist strategy and keeps the best individuals for the next generation. The results in the experiments show that NNE not only achieves good performance in a lot of constrained optimization problems, but also outperforms most of state-of-art approaches in most of constrained optimization problems, such as ASCHEA and SEMS.