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
相关阅读
opt挂靠的帖子怎么都没了Amex SPG卡送25K points 免费送500刀现金 最佳酒店卡讨论一下FB的经典题read和readline吧DBA_BI 俱乐部成立了!欢迎对数据库和Business Intelligence感兴趣的朋友加入!请教一个问题啊 (转载)学校马上要career fair我是等着现场投还是找现在网上联系我的recruiter投salary VS hourly pay~~~~~~~~~~~~~~~~码农年薪300W是真是假?G家选组opt申请交不交offer letter有什么区别吗?opt 期间有急事回国,拿个icc的offer可以回么,签证会有问题吗?interesting stats for the top internet companies.R&D position in Denver area in Colorado问点关于cracking the code interview 的问题C++职位,做汽车导航心浮气躁的上来求个blessC/C++ Software Engineer,求refer,谢谢!人品跌倒谷底的一贴我来告诉你们这些书呆子,你们为什么斗不过印度人 (转载)问个问题码公工资什么时候能破百万? (转载)