Java shows the usage of External table-external list

Source: Internet
Author: User
Tags addall

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.