1:写一个单例模式
常驻内存模式
Class A(){
Private static A a = new A();
Public A getA(){
Return a;
}
}
自由模式
Class A (){
Private static A a = null;
Public A getA(){
Return a==null?new A():a;
}
}
2: 用一个循环排序一个数组(冒泡肯定不行)
Int list[] = {8,4,5,7,8,4,6,9,3};
For(int i =0;i<list.length;i++){
取到前面两个数据作为初始值
Int one = list[i];
Int two = list[i+1]
If(one > two ){
List[i] = two;
List[i+1] = one;
}
}
3:写一个二叉树的数据结构模型,然后进行遍历
1. Class Tree(){
2.public void all(Tree t){Tree leftTree;
Tree rigthTree;
Object value;
}
System.out.print(t.value)
If(null!=t.leftTree){
All(t.leftTree)
}
If(null!=t.rigthTree){
All(t.rigthTree)
}
}