Thread: JAVA: Linkedlist
-
29-10-2008, 14:36 #1Member
- Registered
- 12/09/04
- Posts
- 3
- iTrader
- 0
- Mentioned
- 0 Post(s)
JAVA: Linkedlist
Schrijf een programma dat een serie van voornamen inleest en opslaat in een LinkedList. Sla geen duplicaten op. Laat de gebruiker toe een voornaam op te zoeken.
import java.util.List;
import java.util.LinkedList;
import java.util.ListIterator;
public class ListTest
{
private static final String Voornamen[] = { "Angelo", "Jef",
"Jonas", "Joey", "Rouslan", "Kenneth" };
// set up and manipulate LinkedList objects
public ListTest()
{
List< String > list1 = new LinkedList< String >();
// add elements to list link
for ( String voornaam : Voornamen )
list1.add( voornaam );
// output List contents
public void printList( List< String > list )
{
System.out.println( "\nlist: " );
for ( String Voornamen : list )
System.out.printf( "%s ", Voornamen );
System.out.println();
} // end method printList
public static void main( String args[] )
{
new ListTest();
}
} // end main
} // end class ListTest
Eclipse geeft fouten weer, iemand die weet wat er fout gaat?no votes
-
-
29-10-2008, 15:17 #2Crew Member
- Registered
- 01/09/02
- Location
- Peutie
- Posts
- 7,664
- iTrader
- 0
- Mentioned
- 4 Post(s)
- Reputation
- 13/105
Er staat op het einde een } te veel en er staat een } te weinig bij uw "public ListTest()" constructor.
Daarnaast gaat dit u geen output bezorgen, ik hoop dat je dat weet.Vanaf nu gaan we verder op BeyondGaming!
In deze thread wordt uitgelegd hoe je jouw account kan migreren.no votes
-
29-10-2008, 18:47 #3
Euh, schoolopdracht?

Vreemde opdracht op zich trouwens, aangezien een list niet echt geschikt is om unieke waarden in op te gaan slaan.Technical JEE consultant: Cronos - Just another geek: web\lab studios
Standards aren't for innovation as it happens, they are for innovation that has gotten so old that everybody is ready to just conform to the accepted best practices and move on to figuring out something else.. (Hans Reiser)no votes
-
29-10-2008, 19:08 #4Approved 9liver
- Registered
- 18/01/04
- Location
- Melle
- Posts
- 10,535
- iTrader
- 56 (100%)
- Mentioned
- 0 Post(s)
- Reputation
- 27/102
Hij checkt zelf nog niet of er duplicaten zijn
“In terms of how we evaluate schooling, everything is about working by yourself. If you work with someone else, it’s called cheating. Once you get out in the real world, everything you do involves working with other people.”
PSN: Cycloon - Final Fantasy XIV: A realm reborn characterno votes
