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 3 of 3

Thread: Comparing elements of an arrayList with an array?

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Location
    London
    Posts
    15
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Comparing elements of an arrayList with an array?

    I'm building a program where users need to click on polygons in a certain order to be correct (the polygons are fashioned like "strokes" that make up a Japanese Kanji character), each polygon is numbered and when clicked on the number goes into an arrayList. When all the polygons have been clicked, the numbers in the arrayList would be compared with an array that has the correct sequence of numbers for that particular Kanji.
    After some online searching I've found ways to compare elements in two arrays with each other and the same for elements in the arrayLists, but nothing on comparing elements of an arrayList with an array.
    Does anyone know a way of doing it? Thanks.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Comparing elements of an arrayList with an array?

    You can get items from an ArrayList by index, just like an array. Can't you just loop through every index, comparing each?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Location
    London
    Posts
    15
    My Mood
    Confused
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Comparing elements of an arrayList with an array?

    I'm not that experienced in Java unfortunately so the thought didn't occur to me.. I will attempt that, thank you.

Similar Threads

  1. Duplicate elements in 2 Arraylist
    By tcstcs in forum Collections and Generics
    Replies: 3
    Last Post: April 18th, 2011, 12:56 AM
  2. URGENT!!!! help with array element comparing
    By Neo in forum Java Theory & Questions
    Replies: 3
    Last Post: March 3rd, 2011, 08:52 AM
  3. Adding array elements inside a loop
    By Scotty in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 28th, 2010, 09:48 PM
  4. accessing elements in a 2d ArrayList
    By Flamespewer in forum Collections and Generics
    Replies: 2
    Last Post: March 8th, 2010, 06:11 PM
  5. Method Adding elements to an array with certain restrictions
    By Newoor in forum Collections and Generics
    Replies: 1
    Last Post: December 13th, 2009, 11:13 AM