File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
src/org/javacore/collection/list Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .javacore .collection .list ; /*
2
+ * Copyright [2015] [Jeff Lee]
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import java .util .ArrayList ;
18
+ import java .util .List ;
19
+ import java .util .ListIterator ;
20
+
21
+ /**
22
+ * @author BYSocket
23
+ * @since 2016-01-06 20:11:00
24
+ * 打印list 全部元素,并找到其中元素aaa删除。要求:所有元素都遍历完
25
+ * ListIterator 的使用
26
+ */
27
+ public class ListT0 {
28
+ public static void main (String [] args ) {
29
+ List <String > list =new ArrayList <>();
30
+ list .add ("1" );
31
+ list .add ("2" );
32
+ list .add ("3" );
33
+ list .add ("4" );
34
+ list .add ("aaa" );
35
+ list .add ("6" );
36
+ list .add ("7" );
37
+
38
+ ListIterator listIterator = list .listIterator ();
39
+ while (listIterator .hasNext ()) {
40
+ Object o = listIterator .next ();
41
+ System .out .println (o );
42
+ if (o .equals ("aaa" )) {
43
+ listIterator .remove ();
44
+ }
45
+ }
46
+ }
47
+
48
+ }
You can’t perform that action at this time.
0 commit comments