How to pass a Linked list as a function parameter in java -


I am struggling in "how to pass a linked list as a function parameter" in java. This method is considered to have another linked list as a parameter, and to add the contents of this linked list to the linked list of the calling instance. Elements should be added only if the element is not already present. All linked elements should be added at the end of the added link.

Every parameter in Java

  This is a simple example: / P> 
    public static zero main (string [] args) {list & lt ;? & Gt; myList = new arreelist & lt; & Gt; (); MyList.add (1); MyList.add ("Sarah"); Process (MyList); Iterator = myList.iterator (); While (this hasNext ()) {System.out.println (it.next ()); }} Public stable zero process (list & lt;? & Gt; list) {list.add ("Johnny"); }   

will output:

  1 All Johnny   

which means that you passed as a parameter The list is actually passed from the context so "Johnny" is added.

This applies to any real object (the object is expanded).

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -