改错误

今天公司面试四个小朋友,想起了我们之前面试的情景,没想到今年还要面试机试,就是找错误。呵呵

他们穿的衣服好像是做推销的,一水的黑西装,女生也是,刚到公司的门口的时候看到他们确实吓了一跳呢,呵呵


下面就是源码


public class SingleSimple {
private static int index = 1;
protected SingleSimple(){
index+= 1;
}

protected SingleSimple(String[] hello1,String[] hello2){
index+= 1;
hello2 = hello;
hello = hello1;
}

private String[] hello={"1","2","3","4","5","6","7"};
public static SingleSimple getEntity(){
return new SingleSimple();
}

public String[] getHello() {
return hello;
}

public void setHello(String[] hello) {
this.hello = hello;
}

public void runArray(){
try{
if(hello.length == 0 || hello == null){
System.out.println("hello error");
} else if(hello.length != 0){
for (int i = 0; i < hello.length; i++) {
if(hello[i].equals("1")){
System.out.println("1");
} else if(hello[i].equals("1")){
System.out.println("1");
} else if(hello[i].equals("2")){
System.out.println("2");
} else if(hello[i].equals("3")){
System.out.println("3");
} else if(hello[i].equals("4")){
throw new Exception("4");
} else if(hello[i].equals("5")){
System.out.println("5");
} else if(hello[i].equals("6")){
System.out.println("6");
} else if(hello[i].equals("7")){
System.out.println("7");
}
}
}
} catch(Exception E){
E.printStackTrace();
}
}

private void helloworld(){
try {
if(index > 2){
throw new Exception();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}




public class TestFactory {
private static SingleSimple ss = null;
private String[] a;
private String[] b;

private TestFactory () { }

public synchronized static SingleSimple newInstance(){
if(ss == null){
ss = new SingleSimple();
}
return ss;
}

public String[] display(){
ss = new SingleSimple(a,b);
ss.runArray();
this.xy();
return ss.getHello();
}

private void xy(){
ss.setHello(b);
ss.runArray();
}

public static void main(String[] args){
TestFactory t = new TestFactory();
SingleSimple x = t.newInstance();
String[] h = t.display();
String[] temp = new String[3];
int n = 0;
for (int i = 0; i <= h.length; i++) {
if(i%2 != 0){
temp[n]=h[i];
n ++;
}
}
x.setHello(temp);
}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值