使用java 创建一个树对象,和遍历树的方法。
这个类是使用面向对象的方式,使用对象组装了一个树。然后使用遍历出来,详情看代码。
package cn.com.chx.website.util;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* Title: 存储栏目对象
* </p>
* <p>
* Description: 栏目对象实体
* </p>
* <p>
* Copyright: Copyright 2015 普巴软件有限公司. All rights reserved.
* </p>
* <p>
* Company: 普巴软件有限公司
* </p>
*
* @author WangXuDong
* @date 2015年10月13日
*/
public class CatalogTree {
public static void main(String[] args) {
// String string = shuju[i];
// System.out.println(string);
//获取所有的一级菜单
//String[] shuju1 = new String[]{"004","005","003"};
CatalogTreeEntity cte = new CatalogTreeEntity(); //保存生成的树对象
CatalogTreeEntity ce004 = new CatalogTreeEntity(); //服装对象
ce004.setId("1");
ce004.setCaId("服装");
cte = getCataTree(ce004,1); //查找