📄 listtest.java
字号:
// ListTest.java
// Class ListTest
public class ListTest {
public static void main( String args[] )
{
List objList = new List(); // create the List container
// Create objects to store in the List
Boolean b = Boolean.TRUE;
Character c = new Character( '$' );
Integer i = new Integer( 34567 );
String s = "hello";
// Use the List insert methods
objList.insertAtFront( b );
objList.print();
objList.insertAtFront( c );
objList.print();
objList.insertAtBack( i );
objList.print();
objList.insertAtBack( s );
objList.print();
// Use the List remove methods
Object removedObj;
try {
removedObj = objList.removeFromFront();
System.out.println(
removedObj.toString() + " removed" );
objList.print();
removedObj = objList.removeFromFront();
System.out.println(
removedObj.toString() + " removed" );
objList.print();
removedObj = objList.removeFromBack();
System.out.println(
removedObj.toString() + " removed" );
objList.print();
removedObj = objList.removeFromBack();
System.out.println(
removedObj.toString() + " removed" );
objList.print();
}
catch ( EmptyListException e ) {
System.err.println( "\n" + e.toString() );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -