Wednesday, June 2, 2010

What Do The > On Facebook Chat Mean

Eg linked lists in Java

Some of the data structures that are frequently used in programming are lists, stacks and queues. But probably (at least I do) when we will implement some utility to these data structures, remember the name of the class as it was used (in Java) is an exercise in memory (not only Java but with any language), unless we are constantly in the same programming language. Here I put a very simple example that demonstrates the use of lists in Java.
We have to import java.util package that contains classes for handling and iterators lists. You can download the source code link. _______________________________________________________

/ / Example of use of lists in Java

/ / Author: Juan Jose Fumero Alfonso
/ / Blog: snaterk.blogspot.com import java.util .*;
public class MyList { public
static void main
(
String [] args) {
/ / We create it lists List
a = new LinkedList ();


/ / elements aƱadido a la
list
for (int
i = 0 ; i \u0026lt; 100

; i + +) add

/ / We print it list

System

. October println (a);
.

/ / If we are going to print them by the elements

ListIterator it = a.

listIterator (); / / Iterator it2 = a.iterator ();
while
(It.
hasNext ())



 out.     println (It. 
next ());
/ / Delete all items in the list

a. RemoveAll (a);
/ / Print the result
System. out. println (a);

System. exit (0
) }} _______________________________________________________

0 comments:

Post a Comment