DESKTOP-EA11HIB_20200908-蒋宇飞
一、总结
1.队列
(1)以字符串形式右侧为头左侧为尾
x.offerFirst( "1" );
x.offerFirst( "2" );
System.out.println( x );//[2,1]
System.out.println( x.peekLast() ); //1
System.out.println( x );//[2,1]
System.out.println( x.pollLast() ); // 1
System.out.println( x );//[2]
(2)以字符串形式左侧为头右侧为尾
y.offerLast( "1" );
y.offerLast( "2" );
System.out.println( y );//[1,2]
System.out.println( y.peekFirst() ); //1
System.out.println( y );//[1,2]
System.out.println( y.pollFirst() ); // 1
System.out.println( y );//[2]
2.栈
(1)以字符串形式右侧为栈顶
x.offerLast( "1" );
x.offerLast( "2" );
System.out.println( x );//[1,2]
System.out.println( x.peekLast() );//2
System.out.println( x );//[1,2]
System.out.println( x.pollLast() );//2
System.out.println( x );//[1]
(2)以字符串形式左侧为栈顶
y.offerFirst( "1" );
y.offerFirst( "2" );
System.out.println( y );//[2,1]
System.out.println( y.peekFirst() );//2
System.out.println( y );//[2,1]
System.out.println( y.pollFirst() );//2
System.out.println( y );//[1]
二、感想
宿舍人多,作息时间不同,想早睡也睡不着,要是想睡就能睡着就好了
近期评论