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 的大作中提到】
: 很简单,呵呵。写一个函数的具体实现。
: /**
: * 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 的大作中提到】
: 很简单,呵呵。写一个函数的具体实现。
: /**
: * 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
相关阅读
纠结,国内¥25W的工作与湾区$11W的工作总感觉自己没准备好,不敢投简历onsite结果等了快两周了。。不淡定了。。求祝福。。问身份要求问出了个杯具刚用offer push了一个公司下午电面感觉不好,求建议我觉得我的面试中,我有点在dominating,不太好吧?第一个H1B网上批了,还没拿到正式文件,能不能去上班呢?HR会直接联系推荐人吗,在给回复之前Amazon 电面, conference call 怎么用?H1B RenewJob Opening: ERP engineer in Washington D.C.急问关于video interview技术设备 (转载)恳求推荐data mining, statistical modelling 经典教材!!!快要得抑郁症了请大牛们推荐java junior position面试的书 (转载)求指路人!!做研究的如何转向公司?谁来科普一下背景调查都查些什么东西?Positions: Statistics, Econometrics, or Economics/Applied Mathematics (代人发)on-site时西装里面能穿羊毛衫吗?