Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

copy linked list

// Java code to illustrate clone() method
import java.io.*;
import java.util.LinkedList;
  
public class LinkedListDemo {
      
    public static void main(String args[]) {
      
        // Creating an empty LinkedList
        LinkedList<String> list = new LinkedList<String>();
      
        // Use add() method to add elements in the list
        list.add("Geeks");
        list.add("for");
        list.add("Geeks");
        list.add("10");
        list.add("20");
      
        // Displaying the list
        System.out.println("First LinkedList:" + list);
      
        // Creating another linked list and copying
        LinkedList sec_list = new LinkedList();
        sec_list = (LinkedList) list.clone();
          
        // Displaying the other linked list
        System.out.println("Second LinkedList is:" + sec_list);
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: input using stringbuffer 
Java :: Java List Add Elements using add() method 
Java :: multiple inheritance using interface in java 
Java :: Java Thread Example by implementing Runnable interface 
Java :: better way to check string on null and empty java 
Java :: and roid shape setCornerRadii 
Java :: remove tableview separator lines in javafx 
Java :: java letter to number 
Java :: Using multiple delimiters with String Tokenizer 
Java :: How to merge two sorted arrays in Java? 
Java :: how to compute age from local date 
Java :: get max of array java 
Java :: maven skip make-assembly 
Java :: startactivity not working in android adapter 
Java :: no of words in a string in java 
Java :: default java keystore 
Java :: java class in dataweave 
Java :: Java boolean Keyword 
Java :: how to check when edittext clicked android 
Java :: how to know if a file is iso-8859-1 encoded in java 
Java :: set union java 
Java :: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251) 
Java :: how to print all package in java 
Java :: java basic program 
Java :: transparent border of jtextfield in java 
Java :: miles to km converter programm in java 
Java :: feign client url from properties 
Java :: fibonacci of 6 
Java :: java string replace 
Java :: run java file 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =