当前位置:网站首页>iterator中的next()为什么要强转?
iterator中的next()为什么要强转?
2022-06-28 19:52:00 【Yuyy】
本文最后更新于 914 天前,其中的信息可能已经有所发展或是发生改变。
List<MyFile> myFileList=new LinkedList<>();
Iterator iterator=myFileList.iterator();
while (iterator.hasNext()){
MyFile myFile=(MyFile) iterator.next();
}- 因为迭代器没有定义泛型,next()默认会返回Object,所以需要强转。
- 加上泛型就OK,Iterator< MyFile> it = myFileList.iterator();
Post Views: 425
边栏推荐
猜你喜欢
随机推荐
Pyinstaller打包pikepdf失败的问题排查
Analysis of all knowledge points of TCP protocol in network planning
bluecmsv1.6代码审计
2788.Cifera
jsp中获取session中的值
Kaggle gastrointestinal image segmentation competition baseline
ArrayList of collection
rsync远程同步
Autumn recruitment experience sharing | how to prepare for bank interview
2788.Cifera
Quaternion quaternion and Euler angle transformation in ROS
集合之ArrayList
CSDN salary increase technology selenium automated test stack summary
Markdown mermaid種草(1)_ mermaid簡介
How to obtain the coordinates of the aircraft passing through both ends of the radar
C # connect to the database to complete the operation of adding, deleting, modifying and querying
Demo of integrated development of intelligent computing system 3 plugin
Pyinstaller打包pikepdf失败的问题排查
Use of WC command
Demo of intelligent computing system 2 bangc operator development (heterogeneous programming flow of CPU and mlu270)









