Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: finding specified NUMBERS in an array

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default finding specified NUMBERS in an array

    for (i = 0 ; i < list.length ; i++){
    if (list[i] == list2[0])
    location = i;
    break;


    ok i have that code which locates a single number but i cant figure out how to continue in the sequence,
    i have an array of 50 which is loaded with random numbers between 1-9..
    then i input 4 numbers which i place in an array of 4...

    then once the random numbers get displayed the user chooses a sequence of numbers say
    12345678909214326873196782.........

    then the user inputs 9,2,1,4 as the sequence so my question;
    how can i get get past the other 9 in the array, all i have is

    do{
    for (i = 0 ; i < list.length ; i++){
    if (list[i] == list2[0])
    location = i;
    break;
    }
    if (list[location + 1] == list2[1])

    break;


    }
    while (choice == false);


    System.out.println(location);
    }
    }


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: finding specified NUMBERS in an array

    A sequence as in a bunch of single ints, or more like a String?

    That number is a String if just one number.

    put code in [highlight=java] Code [/highlight] .

Similar Threads

  1. random numbers in array please help
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 15th, 2010, 01:54 AM
  2. finding pi
    By gonfreecks in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 2nd, 2010, 05:15 PM
  3. Averaging Numbers in an Array Based on References
    By aussiemcgr in forum Java Theory & Questions
    Replies: 6
    Last Post: August 6th, 2010, 06:39 PM
  4. How to write 2 dimensional array of float numbers to binary file?
    By Ghuynh in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: June 17th, 2010, 04:26 PM
  5. Finding the highest number in an array?
    By halfwaygone in forum Algorithms & Recursion
    Replies: 1
    Last Post: April 17th, 2010, 03:56 PM