http://www.java2s.com/Code/Java/Collections-Data-Structure/LinkedListexample.htm

<HTML>
<HEAD>
    <title> Linked List example : List : Collections Data Structure : Java examples (example source code) Organized by topic </title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">    <meta http-equiv="content-style-type" content="text/css"/>
    <meta name="author" content="Demo Source and Support Ltd."/>
    <meta name="copyright" content="2006 Demo Source and Support Ltd."/>
    <meta name="description" CONTENT=" Linked List example : List : Collections Data Structure : Java examples (example source code) Organized by topic " />
    <meta name="keywords" CONTENT=" Linked List example : List : Collections Data Structure : Java examples (example source code) Organized by topic "/>
<SCRIPT language=javascript1.2>
<!--  document.write('<style type="text/css">.script12hide { display: none; }</style>');  -->
</SCRIPT>
<STYLE type=text/css>
.BackgroundTable {BACKGROUND-COLOR: #fff4c2; BORDER-RIGHT:#ffcc33 1px solid; BORDER-LEFT:#ffcc33 1px solid;BORDER-TOP:#ffcc33 1px solid; BORDER-BOTTOM:#ffcc33 1px solid}
.ContainerTableTOP {MARGIN-BOTTOM: 0px; BORDER-TOP:#ffcc33 1px solid}
.ContainerTableBOTTOM {MARGIN-BOTTOM: 0px; BORDER-BOTTOM:#ffcc33 1px solid}
H1 {color: #FFFFFF; font-weight: normal; FONT-SIZE: 5%; TEXT-DECORATION: none }
A { COLOR: #003399; TEXT-DECORATION: none }
A:hover{text-decoration:underline}
.codeResult {padding: 10px; color:#FFFFFF; background-color:#000000;FONT-SIZE: 100%;}.codeShade {padding: 4px;margin-left: 0em;border-left:#ffcc33 solid 1px;border-top:#ffcc33 solid 1px;border-right:#ffcc33 solid 2px;border-bottom:#ffcc33 solid 2px;margin-top:0.5em;margin-bottom:0.5em;background-color:#FFD;}
.articleProductTitle {padding: 4px;margin-left: 1em;border-left:#ffcc33 solid 1px;border-top:#ffcc33 solid 1px;border-right:#ffcc33 solid 2px;border-bottom:#ffcc33 solid 2px;margin-top:0.5em;margin-bottom:0.5em;background-color:#fff4c2;}
BODY {FONT-SIZE: 83%; FONT-FAMILY: arial, sans-serif}
TD {FONT-SIZE: 83%; FONT-FAMILY: arial, sans-serif}
.fixed_width {FONT-SIZE: 90%; FONT-FAMILY: fixed-width, monospace}
TABLE.content TD {PADDING-RIGHT: 4px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px}
P {FONT-SIZE: 130%;}
LI {FONT-SIZE: 130%;}
.gt {BORDER-COLLAPSE: collapse}
.gt TD {BORDER-RIGHT: #ffcc33 1px solid; PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 0em; PADDING-TOP: 0em}
.JavaCode {background: #fff4c2}
.JavaCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #ffcc33 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #ffcc33 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #ffcc33 1px solid; BACKGROUND-COLOR: #fff4c2}
.JavaTutorial {background: #fff4c2}
.JavaTutorial TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaTutorialSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #ffcc33 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #ffcc33 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #ffcc33 1px solid; BACKGROUND-COLOR: #fff4c2}
.JavaArticle {background: #FFFAE6}
.JavaArticle TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaArticleSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #FFCC00 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #FFCC00 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #FFCC00 1px solid; BACKGROUND-COLOR: #FFFAE6}
.JavaProduct {background: #FFFCE6}
.JavaProduct TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaProductSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #FFE500 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #FFE500 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #FFE500 1px solid; BACKGROUND-COLOR: #FFFCE6}
.JavaAPICode {background: #FAFFE6}
.JavaAPICode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaAPICodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #CCFF00 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #CCFF00 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #CCFF00 1px solid; BACKGROUND-COLOR: #FAFFE6}
.CSharpCode {background: #EBFFE6}
.CSharpCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.CSharpCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #33FF00 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #33FF00 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #33FF00 1px solid; BACKGROUND-COLOR: #EBFFE6}
.CSharpTutorial {background: #FFE6E6}
.CSharpTutorial TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.CSharpTutorialSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #FE1212 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #FE1212 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #FE1212 1px solid; BACKGROUND-COLOR: #FFE6E6}
.ASPCode {background: #e5ecf9}
.ASPCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.ASPCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #3366cc 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #3366cc 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #3366cc 1px solid; BACKGROUND-COLOR: #e5ecf9}
.JavaScriptCode {background: #E6FFE6}
.JavaScriptCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaScriptCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #60BF60 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #60BF60 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #60BF60 1px solid; BACKGROUND-COLOR: #E6FFE6}
.JavaScriptReferenceCode {background: #F0E6FF}
.JavaScriptReferenceCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.JavaScriptReferenceCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #400099 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #400099 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #400099 1px solid; BACKGROUND-COLOR: #F0E6FF}
.HTMLCSSCode {background: #EBFFE6}
.HTMLCSSCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.HTMLCSSCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #33FF00 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #33FF00 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #33FF00 1px solid; BACKGROUND-COLOR: #EBFFE6}
.HTMLCSSReferenceCode {background: #FFFFBF}
.HTMLCSSReferenceCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.HTMLCSSReferenceCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #CCCC00 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #CCCC00 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #CCCC00 1px solid; BACKGROUND-COLOR: #FFFFBF}
.CCode {background: #E2DEFC}
.CCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.CCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #9B72CF 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #9B72CF 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #9B72CF 1px solid; BACKGROUND-COLOR: #E2DEFC}
.CTutorial {background: #FFE6E6}
.CTutorial TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.CTutorialSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #FE1212 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #FE1212 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #FE1212 1px solid; BACKGROUND-COLOR: #FFE6E6}
.CppCode {background: #FFFFBF}
.CppCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.CppCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #B3B300 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #B3B300 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #B3B300 1px solid; BACKGROUND-COLOR: #FFFFBF}
.PhpCode {background: #F7E6FF}
.PhpCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.PhpCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #660099 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #660099 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #660099 1px solid; BACKGROUND-COLOR: #F7E6FF}
.PythonCode {background: #F7E6FF}
.PythonCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.PythonCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #660099 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #660099 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #660099 1px solid; BACKGROUND-COLOR: #F7E6FF}
.SQLServerCode {background: #e5ecf9}
.SQLServerCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.SQLServerCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #3366cc 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #3366cc 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #3366cc 1px solid; BACKGROUND-COLOR: #e5ecf9}
.OracleCode {background: #e5ecf9}
.OracleCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.OracleCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #3366cc 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #3366cc 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #3366cc 1px solid; BACKGROUND-COLOR: #e5ecf9}
.PostgreSQLCode {background: #e5ecf9}
.PostgreSQLCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.PostgreSQLCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #3366cc 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #3366cc 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #3366cc 1px solid; BACKGROUND-COLOR: #e5ecf9}
.SQLCode {background: #D2E4FC}
.SQLCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.SQLCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #75A3ED 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #75A3ED 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #75A3ED 1px solid; BACKGROUND-COLOR: #D2E4FC}
.VBCode {background: #FFF7E6}
.VBCode TD {WHITE-SPACE: nowrap; BORDER-RIGHT-WIDTH: 0px! important}
.VBCodeSel TD {BORDER-RIGHT: medium none; PADDING-RIGHT: 10px; BORDER-TOP: #FFB200 1px solid; PADDING-LEFT: 0.4em; FONT-WEIGHT: bold; PADDING-BOTTOM: 0.1em; BORDER-LEFT: #FFB200 1px solid; PADDING-TOP: 1px; BORDER-BOTTOM: #FFB200 1px solid; BACKGROUND-COLOR: #FFF7E6}
</STYLE>

<SCRIPT language=javascript><!--
//         ----------------------------------
//         used for dynamic function generation on event handlers
var loaddef = "";
var resizedef = "";
//         ----------------------------------
//         cross-browser functions
var IE_all_cache = new Object();
function IE_getElementById(id) {
    if (IE_all_cache[id] == null) {
        IE_all_cache[id] = document.all[id];
    }
    return IE_all_cache[id];
}
if (document.all) {
    if (!document.getElementById) {
        document.getElementById = IE_getElementById;
    }
}
//        -----------------------------------
//         Browser detection
var agt = navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_opera;
var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all;
--></SCRIPT>

</HEAD>
<!-- logo and ad -->
<BODY bgColor=white topMargin=3 marginheight="3">
<table cellpadding=0 cellspacing=0 border=0>
 <tr><td valign=top>
 <a href="http://www.java2s.com"><IMG height=72 src="http://www.java2s.com/style/logo.png" width=130 border=0>
 </a>
 </td>
 <td valign=top>
<!-- FASTCLICK.COM 468x60 and 728x90 Banner CODE for java2s.com --><script language="javascript" src="http://media.fastclick.net/w/get.media?sid=24280&m=1&tp=5&d=j&t=n"></script><noscript><a href="http://media.fastclick.net/w/click.here?sid=24280&m=1&c=1" target="_blank"><img src="http://media.fastclick.net/w/get.media?sid=24280&m=1&tp=5&d=s&c=1"width=728 height=90 border=1></a></noscript><!-- FASTCLICK.COM 468x60 and 728x90 Banner CODE for java2s.com --> </td></tr>
</table>
 <H1>Linked List example : List : Collections Data Structure : Java examples (example source code) Organized by topic<H1>
<TABLE id=ln style="MARGIN-RIGHT: -3px" cellSpacing=0 cellPadding=0 align=left border=0>
<TBODY>
<TR vAlign=top>
    <TD width=150>
        <TABLE class=gt cellSpacing=0 cellPadding=2 width="100%" border=0>
            <TBODY>
                          <TR class=JavaCodeSel><TD align="center"><B><A href="http://www.java2s.com/Code/Java/CatalogJava.htm">Java</A></B></TD></TR>
        <TR><TD><IMG height=2   width=1 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaTutorial width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Tutorial/Java/CatalogJava.htm">Java Tutorial</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaArticle width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Article/Java/CatalogJava.htm">Java Articles</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaProduct width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Product/Java/CatalogJava.htm">Java Products</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaAPICode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/JavaAPI/CatalogJavaAPI.htm">Java by API</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=CSharpCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/CSharp/CatalogCSharp.htm">C# / C Sharp</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=CSharpTutorial width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Tutorial/CSharp/CatalogCSharp.htm">C#/CSharp Tutorial</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=ASPCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/ASP/CatalogASP.htm">ASP.Net</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaScriptCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/JavaScript/CatalogJavaScript.htm">JavaScript DHTML</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaScriptReferenceCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/JavaScriptReference/CatalogJavaScriptReference.htm">JavaScript Reference</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=HTMLCSSCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/HTMLCSS/CatalogHTMLCSS.htm">HTML / CSS</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=HTMLCSSReferenceCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/HTMLCSSReference/CatalogHTMLCSSReference.htm">HTML CSS Reference</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=CCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/C/CatalogC.htm">C / ANSI-C</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=CTutorial width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Tutorial/C/CatalogC.htm">C Tutorial</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=CppCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/Cpp/CatalogCpp.htm">C++</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=PhpCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/Php/CatalogPhp.htm">PHP</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=PythonCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/Python/CatalogPython.htm">Python</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=SQLServerCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/SQLServer/CatalogSQLServer.htm">SQL Server / T-SQL</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=OracleCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/Oracle/CatalogOracle.htm">Oracle PL/SQL</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=PostgreSQLCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/PostgreSQL/CatalogPostgreSQL.htm">PostgreSQL</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=SQLCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/SQL/CatalogSQL.htm">SQL / MySQL</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=VBCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><A href="http://www.java2s.com/Code/VB/CatalogVB.htm">VB.Net</a></TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
        <TD style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">
        <DIV style="MARGIN-RIGHT: 5px">
        <TABLE class=JavaCode width="95%"  cellSpacing=0 cellPadding=2 border=0>
        <TBODY><TR><TD align="center"><script type="text/javascript">
<!-- 
google_ad_client = "pub-1130008796007602";
google_ad_width = 120;
google_ad_height = 90;
google_ad_format = "120x90_0ads_al";
google_ad_channel = "";
google_color_border = "fff4c2";
google_color_bg = "fff4c2";
google_color_link = "000000";
google_color_text = "000000";
google_color_url = "99CC99";
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> 
</TD></TR></TBODY>
        </TABLE>
        </DIV>
        </TD>
<TR><TD><IMG height=0 width=0 border=0></TD></TR>
<TR><TD><IMG id=ln_2 height=0 width=1 border=0></TD></TR>

            </TBODY>
        </TABLE>
    </TD>
    <TD width=8 style="BORDER-TOP:#ffcc33  1px solid; BORDER-BOTTOM:#ffcc33 1px solid" bgColor=#fff4c2>
        <img id=ln_image height=500 src="http://www.java2s.com/style/dot_clear.gif" width=1 border=0>
    </TD>
</TR>
</TBODY>
</TABLE>
<SCRIPT language=javascript1.2><!--
function sizeLeftNav() {
    var marker = document.getElementById('bottom_marker');
    var im = document.getElementById( 'ln_image' );
    var table = document.getElementById('ln');
    if (marker != null) {
var tries = 0;

while (tries < 30) {
tries++;
var oldMarkerPos = marker.offsetTop;
var oldIMHeight = im.height;
im.height = (marker.offsetTop +  marker.offsetHeight )-(table.offsetTop+2);
var verticalStretch = document.getElementById('ln_2');
var oldVerticleStretchHeight = verticalStretch.height;
verticalStretch.height = im.height - (verticalStretch.offsetParent.offsetTop +
verticalStretch.offsetTop +2);
var oldWhitespaceHeight;
var whitespace = document.getElementById('whitespace');
if (whitespace != null) {
    oldWhitespaceHeight = whitespace.height;
    whitespace.height = table.offsetHeight - (whitespace.offsetParent.offsetParent.offsetTop -
        table.offsetTop + (document.getElementById('forkbottom').offsetHeight));
}
var oldRightnavHeight;
var rightnav = document.getElementById('rn_image');
if (rightnav != null) {
    oldRightnavHeight = rightnav.height;
    rightnav.height = whitespace.height + rightnav.offsetTop - whitespace.offsetTop;
}
var deltaMarkerPos = marker.offsetTop - oldMarkerPos;
var deltaIMHeight = im.height - oldIMHeight;
if (deltaMarkerPos == deltaIMHeight) {
   if (deltaMarkerPos > 0) {
          // Take back what we did, it didn't help
      im.height = oldIMHeight;
      verticalStretch.height = oldVerticleStretchHeight;
      if (whitespace != null) {
          whitespace.height = oldWhitespaceHeight;
      }
      if (rightnav != null) {
          rightnav.height = oldRightnavHeight;
      }
   }
   break;
}
}
}

}
resizedef += "sizeLeftNav(); ";
loaddef += "sizeLeftNav(); ";
//        --></SCRIPT>

<TABLE cellSpacing=0 cellPadding=0 bgColor=ffcc33 border=0>
<TBODY>
<TR>
    <TD width="100%"><IMG height=1 alt="" width=1></TD>
    <TD width=10><IMG height=1 alt="" width=1></TD>
</TR>
</TBODY>
</TABLE>

<TABLE cellSpacing=0 cellPadding=2 bgColor=#fff4c2 border=0><TBODY><TR>  <TD class=gl noWrap width="60%"><a href="http://www.java2s.com/Code/Java/CatalogJava.htm"><B>Java Home&nbsp;</a>&raquo;&nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/CatalogCollections-Data-Structure.htm"> Collections Data Structure &nbsp;&nbsp;</a>&raquo;&nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/List.htm">[&nbsp; List &nbsp;]&nbsp;</a></B></TD>  <TD align=right width="10%"><a href="http://www.java2s.com/Code/Java/ScreenShotIndex.htm">Screenshots</a>&nbsp;</TD>  <TD vAlign=center noWrap align=right width="30%"> <FORM style="MARGIN: 2px" name=gs2 method=GET action=http://www.google.com/custom>  <INPUT TYPE=text name=q size=20 maxlength=255 value="">  <INPUT style="FONT-WEIGHT: normal; FONT-SIZE: 90%; LINE-HEIGHT: normal; FONT-STYLE: normal; FONT-VARIANT: normal" type=submit name=sa VALUE="Search in Collections Data Structure">  <INPUT type=hidden name=cof VALUE="S:http://www.java2s.com";AH:center;AWFID:048d0478e57b2768;">  <input type=hidden name=domains value="www.java2s.com/Code/Java/Collections-Data-Structure/">  <input type=hidden  name=sitesearch value="www.java2s.com/Code/Java/Collections-Data-Structure/" checked> </FORM> </TD></TR></TBODY></TABLE><TABLE cellSpacing=0 cellPadding=0 align=left border=0>
<TBODY>
<TR>
     <TD><IMG id=whitespace height=500 src="http://www.java2s.com/style/dot_clear.gif" width=8 align=top border=0></TD>
</TR>
<TR>
     <TD id=forkbottom>&nbsp;</TD>
</TR>
</TBODY>
</TABLE>
<br><br><br><TABLE width="800"  style=" BORDER-RIGHT:#ffcc33 1px solid; BORDER-LEFT:#ffcc33 1px solid;BORDER-TOP:#ffcc33 1px solid; BORDER-BOTTOM:#ffcc33 1px solid" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
    <TD align=left>
<script type="text/javascript"><!--
google_ad_client = "pub-1130008796007602";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "fff4c2";
google_color_bg = "FFFFFF";
google_color_link = "0000ff";
google_color_url = "F7E6FF";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
     </TD>
<td align=right><script type="text/javascript"><!--
google_ad_client = "pub-1130008796007602";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "fff4c2";
google_color_bg = "FFFFFF";
google_color_link = "0000ff";
google_color_url = "F7E6FF";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td></TR>
</TBODY>
</TABLE>
<TABLE style="MARGIN-BOTTOM: 6px; BORDER-BOTTOM:#ffcc33 1px solid" cellSpacing=0 cellPadding=2 border=0>
<TBODY>
<TR><td height=30 width="100%"></TD></TR>
<TR>
<td bgcolor="white" >
<font size=+2>Linked List example</font>
</TD>
</TR>
</TBODY>
</TABLE>
<TABLE border=0>
<TBODY>
<TR>
<td height=30 width="100%">
</TD>
</TR>
<TR>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">

</TD>
</TR>
</TBODY>
</TABLE>



<table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">
   <tr>
  <!-- start source code -->
   <td nowrap="nowrap" valign="top" align="left">
    <div class="codeShade"><code>
<font color="#ffffff"></font><br/>
<font color="#3f7f5f">/*</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;Copyright&nbsp;(c)&nbsp;2000&nbsp;David&nbsp;Flanagan.&nbsp;&nbsp;All&nbsp;rights&nbsp;reserved.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;This&nbsp;code&nbsp;is&nbsp;from&nbsp;the&nbsp;book&nbsp;Java&nbsp;Examples&nbsp;in&nbsp;a&nbsp;Nutshell,&nbsp;2nd&nbsp;Edition.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;It&nbsp;is&nbsp;provided&nbsp;AS-IS,&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY&nbsp;either&nbsp;expressed&nbsp;or&nbsp;implied.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;You&nbsp;may&nbsp;study,&nbsp;use,&nbsp;and&nbsp;modify&nbsp;it&nbsp;for&nbsp;any&nbsp;non-commercial&nbsp;purpose.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;You&nbsp;may&nbsp;distribute&nbsp;it&nbsp;non-commercially&nbsp;as&nbsp;long&nbsp;as&nbsp;you&nbsp;retain&nbsp;this&nbsp;notice.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;For&nbsp;a&nbsp;commercial&nbsp;use&nbsp;license,&nbsp;or&nbsp;to&nbsp;purchase&nbsp;the&nbsp;book&nbsp;(recommended),</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*&nbsp;visit&nbsp;http://www.davidflanagan.com/javaexamples2.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f7f5f">*/</font><br/>
<font color="#ffffff"></font><br/>
<font color="#3f5fbf">/**</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;This&nbsp;class&nbsp;implements&nbsp;a&nbsp;linked&nbsp;list&nbsp;that&nbsp;can&nbsp;contain&nbsp;any&nbsp;type&nbsp;of&nbsp;object&nbsp;that</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;implements&nbsp;the&nbsp;nested&nbsp;Linkable&nbsp;interface.&nbsp;Note&nbsp;that&nbsp;the&nbsp;methods&nbsp;are&nbsp;all</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;synchronized,&nbsp;so&nbsp;that&nbsp;it&nbsp;can&nbsp;safely&nbsp;be&nbsp;used&nbsp;by&nbsp;multiple&nbsp;threads&nbsp;at&nbsp;the&nbsp;same</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*&nbsp;time.</font><br/>
<font color="#ffffff">&nbsp;</font><font color="#3f5fbf">*/</font><br/>
<font color="#7f0055"><b>public&nbsp;class&nbsp;</b></font><font color="#000000">LinkedList&nbsp;</font><font color="#000000">{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;This&nbsp;interface&nbsp;defines&nbsp;the&nbsp;methods&nbsp;required&nbsp;by&nbsp;any&nbsp;object&nbsp;that&nbsp;can&nbsp;be</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;linked&nbsp;into&nbsp;a&nbsp;linked&nbsp;list.</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;interface&nbsp;</b></font><font color="#000000">Linkable&nbsp;</font><font color="#000000">{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">Linkable&nbsp;getNext</font><font color="#000000">()</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Returns&nbsp;the&nbsp;next&nbsp;element&nbsp;in&nbsp;the&nbsp;list</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">setNext</font><font color="#000000">(</font><font color="#000000">Linkable&nbsp;node</font><font color="#000000">)</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Sets&nbsp;the&nbsp;next&nbsp;element&nbsp;in&nbsp;the&nbsp;list</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;This&nbsp;class&nbsp;has&nbsp;a&nbsp;default&nbsp;constructor:&nbsp;public&nbsp;LinkedList()&nbsp;{}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;This&nbsp;is&nbsp;the&nbsp;only&nbsp;field&nbsp;of&nbsp;the&nbsp;class.&nbsp;It&nbsp;holds&nbsp;the&nbsp;head&nbsp;of&nbsp;the&nbsp;list&nbsp;*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">Linkable&nbsp;head;</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;Return&nbsp;the&nbsp;first&nbsp;node&nbsp;in&nbsp;the&nbsp;list&nbsp;*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;synchronized&nbsp;</b></font><font color="#000000">Linkable&nbsp;getHead</font><font color="#000000">()&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">head;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;Insert&nbsp;a&nbsp;node&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the&nbsp;list&nbsp;*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;synchronized&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">insertAtHead</font><font color="#000000">(</font><font color="#000000">Linkable&nbsp;node</font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">node.setNext</font><font color="#000000">(</font><font color="#000000">head</font><font color="#000000">)</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">head&nbsp;=&nbsp;node;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;Insert&nbsp;a&nbsp;node&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;list&nbsp;*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;synchronized&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">insertAtTail</font><font color="#000000">(</font><font color="#000000">Linkable&nbsp;node</font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">head&nbsp;==&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">head&nbsp;=&nbsp;node;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>else&nbsp;</b></font><font color="#000000">{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Linkable&nbsp;p,&nbsp;q;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>for&nbsp;</b></font><font color="#000000">(</font><font color="#000000">p&nbsp;=&nbsp;head;&nbsp;</font><font color="#000000">(</font><font color="#000000">q&nbsp;=&nbsp;p.getNext</font><font color="#000000">())&nbsp;</font><font color="#000000">!=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">;&nbsp;p&nbsp;=&nbsp;q</font><font color="#000000">)</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">/*&nbsp;no&nbsp;body&nbsp;*/</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">p.setNext</font><font color="#000000">(</font><font color="#000000">node</font><font color="#000000">)</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;Remove&nbsp;and&nbsp;return&nbsp;the&nbsp;node&nbsp;at&nbsp;the&nbsp;head&nbsp;of&nbsp;the&nbsp;list&nbsp;*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;synchronized&nbsp;</b></font><font color="#000000">Linkable&nbsp;removeFromHead</font><font color="#000000">()&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Linkable&nbsp;node&nbsp;=&nbsp;head;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">node&nbsp;!=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">head&nbsp;=&nbsp;node.getNext</font><font color="#000000">()</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">node.setNext</font><font color="#000000">(</font><font color="#7f0055"><b>null</b></font><font color="#000000">)</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">node;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**&nbsp;Remove&nbsp;and&nbsp;return&nbsp;the&nbsp;node&nbsp;at&nbsp;the&nbsp;end&nbsp;of&nbsp;the&nbsp;list&nbsp;*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;synchronized&nbsp;</b></font><font color="#000000">Linkable&nbsp;removeFromTail</font><font color="#000000">()&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">head&nbsp;==&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;null</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Linkable&nbsp;p&nbsp;=&nbsp;head,&nbsp;q&nbsp;=&nbsp;null,&nbsp;next&nbsp;=&nbsp;head.getNext</font><font color="#000000">()</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">next&nbsp;==&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">head&nbsp;=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">p;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>while&nbsp;</b></font><font color="#000000">((</font><font color="#000000">next&nbsp;=&nbsp;p.getNext</font><font color="#000000">())&nbsp;</font><font color="#000000">!=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">q&nbsp;=&nbsp;p;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">p&nbsp;=&nbsp;next;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">q.setNext</font><font color="#000000">(</font><font color="#7f0055"><b>null</b></font><font color="#000000">)</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">p;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;Remove&nbsp;a&nbsp;node&nbsp;matching&nbsp;the&nbsp;specified&nbsp;node&nbsp;from&nbsp;the&nbsp;list.&nbsp;Use&nbsp;equals()</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;instead&nbsp;of&nbsp;==&nbsp;to&nbsp;test&nbsp;for&nbsp;a&nbsp;matched&nbsp;node.</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;synchronized&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">remove</font><font color="#000000">(</font><font color="#000000">Linkable&nbsp;node</font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">head&nbsp;==&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">node.equals</font><font color="#000000">(</font><font color="#000000">head</font><font color="#000000">))&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">head&nbsp;=&nbsp;head.getNext</font><font color="#000000">()</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Linkable&nbsp;p&nbsp;=&nbsp;head,&nbsp;q&nbsp;=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>while&nbsp;</b></font><font color="#000000">((</font><font color="#000000">q&nbsp;=&nbsp;p.getNext</font><font color="#000000">())&nbsp;</font><font color="#000000">!=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">node.equals</font><font color="#000000">(</font><font color="#000000">q</font><font color="#000000">))&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">p.setNext</font><font color="#000000">(</font><font color="#000000">q.getNext</font><font color="#000000">())</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">p&nbsp;=&nbsp;q;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;This&nbsp;is&nbsp;a&nbsp;test&nbsp;class&nbsp;that&nbsp;implements&nbsp;the&nbsp;Linkable&nbsp;interface</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>static&nbsp;class&nbsp;</b></font><font color="#000000">LinkableInteger&nbsp;</font><font color="#7f0055"><b>implements&nbsp;</b></font><font color="#000000">Linkable&nbsp;</font><font color="#000000">{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>int&nbsp;</b></font><font color="#000000">i;&nbsp;</font><font color="#3f7f5f">//&nbsp;The&nbsp;data&nbsp;contained&nbsp;in&nbsp;the&nbsp;node</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">Linkable&nbsp;next;&nbsp;</font><font color="#3f7f5f">//&nbsp;A&nbsp;reference&nbsp;to&nbsp;the&nbsp;next&nbsp;node&nbsp;in&nbsp;the&nbsp;list</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#7f0055"><b>int&nbsp;</b></font><font color="#000000">i</font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>this</b></font><font color="#000000">.i&nbsp;=&nbsp;i;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#3f7f5f">//&nbsp;Constructor</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">Linkable&nbsp;getNext</font><font color="#000000">()&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">next;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#3f7f5f">//&nbsp;Part&nbsp;of&nbsp;Linkable</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">setNext</font><font color="#000000">(</font><font color="#000000">Linkable&nbsp;node</font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">next&nbsp;=&nbsp;node;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#3f7f5f">//&nbsp;Linkable</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#000000">String&nbsp;toString</font><font color="#000000">()&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;</b></font><font color="#000000">i&nbsp;+&nbsp;</font><font color="#2a00ff">&#34;&#34;</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}&nbsp;</font><font color="#3f7f5f">//&nbsp;For&nbsp;easy&nbsp;printing</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>boolean&nbsp;</b></font><font color="#000000">equals</font><font color="#000000">(</font><font color="#000000">Object&nbsp;o</font><font color="#000000">)&nbsp;{&nbsp;</font><font color="#3f7f5f">//&nbsp;For&nbsp;comparison</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#7f0055"><b>this&nbsp;</b></font><font color="#000000">==&nbsp;o</font><font color="#000000">)</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;true</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(</font><font color="#000000">!</font><font color="#000000">(</font><font color="#000000">o&nbsp;</font><font color="#7f0055"><b>instanceof&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">))</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;false</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>if&nbsp;</b></font><font color="#000000">(((</font><font color="#000000">LinkableInteger</font><font color="#000000">)&nbsp;</font><font color="#000000">o</font><font color="#000000">)</font><font color="#000000">.i&nbsp;==&nbsp;</font><font color="#7f0055"><b>this</b></font><font color="#000000">.i</font><font color="#000000">)</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;true</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>return&nbsp;false</b></font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#3f5fbf">/**</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;The&nbsp;test&nbsp;program.&nbsp;Insert&nbsp;some&nbsp;nodes,&nbsp;remove&nbsp;some&nbsp;nodes,&nbsp;then&nbsp;print</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;out&nbsp;all&nbsp;elements&nbsp;in&nbsp;the&nbsp;list.&nbsp;It&nbsp;should&nbsp;print&nbsp;out&nbsp;the&nbsp;numbers&nbsp;4,&nbsp;6,</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*&nbsp;3,&nbsp;1,&nbsp;and&nbsp;5</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;</font><font color="#3f5fbf">*/</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#7f0055"><b>public&nbsp;static&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font color="#000000">main</font><font color="#000000">(</font><font color="#000000">String</font><font color="#000000">[]&nbsp;</font><font color="#000000">args</font><font color="#000000">)&nbsp;{</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">LinkedList&nbsp;ll&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkedList</font><font color="#000000">()</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Create&nbsp;a&nbsp;list</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.insertAtHead</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">1</font><font color="#000000">))</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Insert&nbsp;some&nbsp;stuff</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.insertAtHead</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">2</font><font color="#000000">))</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.insertAtHead</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">3</font><font color="#000000">))</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.insertAtHead</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">4</font><font color="#000000">))</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.insertAtTail</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">5</font><font color="#000000">))</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.insertAtTail</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">6</font><font color="#000000">))</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#000000">ll.removeFromHead</font><font color="#000000">())</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Remove&nbsp;and&nbsp;print&nbsp;a&nbsp;node</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#000000">ll.removeFromTail</font><font color="#000000">())</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Remove&nbsp;and&nbsp;print&nbsp;again</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">ll.remove</font><font color="#000000">(</font><font color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">LinkableInteger</font><font color="#000000">(</font><font color="#990000">2</font><font color="#000000">))</font><font color="#000000">;&nbsp;</font><font color="#3f7f5f">//&nbsp;Remove&nbsp;another&nbsp;one</font><br/>
<font color="#ffffff"></font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#3f7f5f">//&nbsp;Now&nbsp;print&nbsp;out&nbsp;the&nbsp;contents&nbsp;of&nbsp;the&nbsp;list.</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#7f0055"><b>for&nbsp;</b></font><font color="#000000">(</font><font color="#000000">Linkable&nbsp;l&nbsp;=&nbsp;ll.getHead</font><font color="#000000">()</font><font color="#000000">;&nbsp;l&nbsp;!=&nbsp;</font><font color="#7f0055"><b>null</b></font><font color="#000000">;&nbsp;l&nbsp;=&nbsp;l.getNext</font><font color="#000000">())</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#000000">System.out.println</font><font color="#000000">(</font><font color="#000000">l</font><font color="#000000">)</font><font color="#000000">;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font><br/>
<font color="#ffffff"></font><br/>
<font color="#000000">}</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><br/>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></code></div>
    
   </td>
  <!-- end source code -->
   </tr>
</table>

<TABLE border=0>
<TBODY>
<TR>
<td height=30 width="100%">
</TD>
</TR>
<TR>
<td height=30 width="100%">
</TD>
</TR>

</TBODY>
</TABLE>
<TABLE style="MARGIN-BOTTOM: 6px; BORDER-BOTTOM:#ffcc33 1px solid" cellSpacing=0 cellPadding=2 border=0>
<TBODY>
<TR height=50><TD></TD></TR>
<TR height=20><TD><font color=#111111 size=+1><b>Related examples in the same category</b></font></TD></TR>
</TBODY>
</TABLE>
<TABLE style="MARGIN-BOTTOM: 6px; BORDER-BOTTOM:#ffcc33 1px solid" cellSpacing=0 cellPadding=2 border=0>
<TBODY>
<TR height=20><TD></TD></TR>
<tr bgcolor="white" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
1. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/AddtoendPerformancecompareLinkListandArrayList.htm"><B>Add to end Performance compare: LinkList and ArrayList</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/AddtoendPerformancecompareLinkListandArrayList.htm">
<img alt="Add to end Performance compare: LinkList and ArrayList" src="http://www.java2s.com/Code/JavaImages/ListDemo.PNG" width=200, height=40></a></td></tr>
<tr bgcolor="fff4c2" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
2. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/AddtostartPerformancecompareLinkListandArrayList.htm"><B>Add to start Performance compare: LinkList and ArrayList</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/AddtostartPerformancecompareLinkListandArrayList.htm">
</a></td></tr>
<tr bgcolor="white" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
3. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Convertarraytolistandsort.htm"><B>Convert array to list and sort</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Convertarraytolistandsort.htm">
<img alt="Convert array to list and sort" src="http://www.java2s.com/Code/JavaImages/Sort.PNG" width=200, height=40></a></td></tr>
<tr bgcolor="fff4c2" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
4. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Shufflealist.htm"><B>Shuffle a list</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Shufflealist.htm">
<img alt="Shuffle a list" src="http://www.java2s.com/Code/JavaImages/Shuffle.PNG" width=200, height=40></a></td></tr>
<tr bgcolor="white" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
5. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Sortalist.htm"><B>Sort a list</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Sortalist.htm">
<img alt="Sort a list" src="http://www.java2s.com/Code/JavaImages/NameSort.PNG" width=200, height=40></a></td></tr>
<tr bgcolor="fff4c2" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
6. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/BidirectionalTraversalwithListIterator.htm"><B>Bidirectional Traversal with ListIterator</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/BidirectionalTraversalwithListIterator.htm">
<img alt="Bidirectional Traversal with ListIterator" src="http://www.java2s.com/Code/JavaImages/MovingPlanets.PNG" width=200, height=40></a></td></tr>
<tr bgcolor="white" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
7. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Intlist.htm"><B>Int list</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Intlist.htm">
<img alt="Int list" src="http://www.java2s.com/Code/JavaImages/IntList.PNG" width=200, height=40></a></td></tr>
<tr bgcolor="fff4c2" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
8. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Listtoarray.htm"><B>List to array</B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/Listtoarray.htm">
</a></td></tr>
<tr bgcolor="white" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
9. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/ListReverseTest.htm"><B>List Reverse Test </B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/ListReverseTest.htm">
</a></td></tr>
<tr bgcolor="fff4c2" vAlign=middle>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="100%">
10. &nbsp;<a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/ListSearchTest.htm"><B>List Search Test </B></a></td><td align="right" ></td>
<td align="right" height= 40><a href="http://www.java2s.com/Code/Java/Collections-Data-Structure/ListSearchTest.htm">
<img alt="List Search Test " src="http://www.java2s.com/Code/JavaImages/SearchTest.PNG" width=200, height=40></a></td></tr>

</TBODY>
</TABLE>

<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><TABLE id=bottom_marker cellSpacing=0 cellPadding=0 border=0>     <TR align=left>
     <TD>
         <A href="http://www.java2s.com">Home</A>|
         <A href=http://www.java2s.com/html/contact.htm>Contact Us</A>
     </Td>
     </TR>
     <TR align=left>
            <TD class=Templatetext>Copyright 2003 - 04 Demo Source and Support. All rights reserved.</TD>
     </TR>
     <TR align=left>
        <TD class=Templatetext>All other trademarks are property of their respective owners.</TD>
     </TR>
</TABLE>
<br>    <br>    <br>    <br>
<SCRIPT language=javascript><!--
if( loaddef != "" ) {
    window.onload=new Function( loaddef );
}
if( resizedef != "" ) {
    window.onresize = new Function( resizedef );
}
//--></SCRIPT>
<br><br><br><br>
 </BODY>
</HTML>

