以下实例演示了使用 listname.add() 和 listname.set() 方法来修改链接中的元素:
import java.util.LinkedList; public class Main { public static void main(String[] a) { LinkedList officers = new LinkedList(); officers.add( "B" ); officers.add( "B" ); officers.add( "T" ); officers.add( "H" ); officers.add( "P" ); System.out.println(officers); officers.set( 2 , "M" ); System.out.println(officers); } } |
以上代码运行输出结果为:
[B, B, T, H, P] [B, B, M, H, P] |
在线实例
字符集 & 工具
最新更新
站点信息
关注我们