Import java. util. Collections list;
Import java. util. vector;
/**
* Sun has already completed the orders table in Java. We only need to use the orders.
* When there are no requirements, you don't have to implement it yourself.
* If you need to implement it on your own, you can also implement it on your own.
* Similar to the previous list, the current interface method can be implemented in the same way.
* This is a simple example. If you are looking at your own response, you can go to this:
* Http://blog.csdn.net/fenglibing/archive/2006/04/19/669456.aspx
* Http://blog.csdn.net/fenglibing/archive/2006/04/19/669362.aspx
*/
Public class linklisttest
{
Public static void main (string [] Arg)
{
// Create a sequence table
Pipeline list head = new pipeline list ();
Int size = 0;
Head. Add (new string ("puppy "));
Head. Add (new string ("us "));
Head. Add (new string ("Japan! "));
Head. Add (2, "");
// The volume table will automatically print all content in the "repeated" mode.
System. Out. println (head );
// Add data to the orders table using collections such as vector or arraylist
Vector v = new vector ();
// Add things to the vector
V. Add ("Big Dog ");
V. Add ("laomei ");
V. Add ("Japan ");
V. Add ("old brother ");
// Add the prefix vector to the end of the forward vertex table.
Head. addall (v );
System. Out. println (head );
// Add the prefix vector to the specified position of the pre-increment table
Head. addall (2, V );
System. Out. println (head );
// Print the content at the specified position
System. Out. println (head. Get (2 ));
Head. addfirst ("first ");
System. Out. println (head );
Head. addlast ("last ");
System. Out. println (head );
// Remove the first
Head. Remove (head. getfirst ());
System. Out. println (head );
// Remove the first one and use the lower-level method. The lower-level starts from 0.
Head. Remove (0 );
System. Out. println (head );
Head. Remove (head. getlast ());
System. Out. println (head );
}
}
The results are as follows:
[Puppies, USA, Xiaoyu, and Japan!]
[Puppy, USA, Xiaoyao, Japan !, Big Dog, laomei, Japan, laomiao]
[Puppy, American, big dog, laomei, Japan, laoxiao, Xiaoxiao, and Japan !, Big Dog, laomei, Japan, laomiao]
Big Dog
[1st, puppy, American, big dog, laomei, Japan, laoxiao, Xiaoxiao, and Japan !, Big Dog, laomei, Japan, laomiao]
[1st, puppy, American, big dog, laomei, Japan, laoxiao, Xiaoxiao, and Japan !, Big Dog, old beauty, Japan, old man, last one]
[Puppy, American, big dog, laomei, Japan, laoxiao, Xiaoxiao, and Japan !, Big Dog, old beauty, Japan, old man, last one]
[America, big dog, old beauty, Japan, old man, small dog, and Japanese !, Big Dog, old beauty, Japan, old man, last one]
[America, big dog, old beauty, Japan, old man, small dog, and Japanese !, Big Dog, laomei, Japan, laomiao]