n*2
2 楼
很简单,呵呵。写一个函数的具体实现。
/**
* Given a list of objects, returns the last object in the list that is an
instance of type Foo.
* @param stuff the list of objects
* @return an object of type Foo
* @throws NoSuchFooException if there is no Foo in the list
*/
Foo getLastFoo(List stuff) throws NoSuchFooException;
/**
* Given a list of objects, returns the last object in the list that is an
instance of type Foo.
* @param stuff the list of objects
* @return an object of type Foo
* @throws NoSuchFooException if there is no Foo in the list
*/
Foo getLastFoo(List stuff) throws NoSuchFooException;
n*2
4 楼
答案:
Foo getLastFoo(List stuff) throws NoSuchFooException {
for (int i=stuff.size()-1; i>=0; i--) {
if (stuff.get(i) instanceof Foo) {
return (Foo) stuff.get(i);
}
}
throw new NoSuchFooException();
}
【在 n**********2 的大作中提到】![](/moin_static193/solenoid/img/up.png)
: 很简单,呵呵。写一个函数的具体实现。
: /**
: * Given a list of objects, returns the last object in the list that is an
: instance of type Foo.
: * @param stuff the list of objects
: * @return an object of type Foo
: * @throws NoSuchFooException if there is no Foo in the list
: */
: Foo getLastFoo(List stuff) throws NoSuchFooException;
Foo getLastFoo(List stuff) throws NoSuchFooException {
for (int i=stuff.size()-1; i>=0; i--) {
if (stuff.get(i) instanceof Foo) {
return (Foo) stuff.get(i);
}
}
throw new NoSuchFooException();
}
【在 n**********2 的大作中提到】
![](/moin_static193/solenoid/img/up.png)
: 很简单,呵呵。写一个函数的具体实现。
: /**
: * Given a list of objects, returns the last object in the list that is an
: instance of type Foo.
: * @param stuff the list of objects
: * @return an object of type Foo
: * @throws NoSuchFooException if there is no Foo in the list
: */
: Foo getLastFoo(List stuff) throws NoSuchFooException;
B*4
6 楼
先谢谢了。
面试就一个题目?还是说coding方面就这一个?
面试就一个题目?还是说coding方面就这一个?
f*D
7 楼
RE
相关阅读
Fresh PhD 一般简历有几页啊?On site 可以要求住便宜的旅馆么?Thank you letter 的subject line是啥?OPT电话加急成功,电邮拒绝,到底怎么说阿?问一下,拿到amazon offer的同学们请教一道yahoo的system design的题目请问大家的今年h1都批了么? non premium的OPT期间,还可以去community college上课吗??Bloomberg onsite哪位筒子在微软工作?有事请教!大家在公司有没有见过以前当professor,现在在做程序员的例子?H1B状态:case not found急问:背景调查,前雇主是深圳华为on site后告别时HM说good luck是不是不好的预兆?Cover letter 是必须的吗?会计硕士容易申请吗,要考G,T吗?OPT case (Vermont) 外加一个小offeronsite 三周半了依然无消息请问 google 要推荐信之后,offer的可能性大么interview 问题