Results 1 to 2 of 2
  1. #1
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

    Default How to get a random next from a scan

    I have a scanner which looks like this:

    scan=new Scanner(generatedString).useDelimiter("\\;");

    generatedString=scan.next();

    So basically the generatedString variable takes the first string in the list, I want to get a random value from the scan.

    e.g.

    generatedString=scan.random selection

    Any ideas on how I could do this?

  2. #2
    JordashTalon is offline Member
    Join Date
    Jan 2009
    Posts
    37
    Rep Power
    0

    Default

    I found one way to do it by using a linked list
    while(scan.hasNext()){
    linkelistVariable.add(scan.next);
    }

    Then I can select a random value from the linked list, that seemed to work.

Similar Threads

  1. Replies: 8
    Last Post: 04-19-2009, 05:50 PM
  2. Scan 1.3
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 05-13-2008, 05:19 PM
  3. Problems passing a scan object to a method
    By xkross in forum New To Java
    Replies: 4
    Last Post: 04-16-2008, 03:56 PM
  4. How to scan your computer for ports in use
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 08:13 PM
  5. Scan 1.0
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 09-22-2007, 11:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •