I wondering how to get started with this. I am working on a method that will take two ints. These ints represent positions in an arraylist of characters. I am trying to determine if the elements of the two positions are equal. If, so display the elements, if not display the int position. For example f the arraylist is as follows:
ArrayList<Character> list = new ArrayList<Character>();
list.add('a');
list.add('f');
list.add('c');
list.add('a');
list.add('s');
I understand how to get elements from an array. I am working on the display. How to display elements of an array at certain positions. If charA and charB are matches then display the positions of the array along with the correctly matched elements as such:
1, 2, 3, 4, T, 6, 7, T, 9
if charA and charB do not match display:
1, 2, 3, 4, 5, 6, 7, 8, 9
I have read it many times, if I understand all I would not be asking for assistance. If you cannot provide assitance without being rude, I would rather you not respond at all.
It seems like you already figured out how to get the Characters from the ArrayList and compare them to see if they are the same. Now all you need to do is write a for loop that prints from 1 . . n where n is the number of elements in your ArrayList. But once you get to the index where the Characters are that you were supposed to compare, you need an if statement to decide whether to print out the Character itself or whether to print out the index.
P.S. Masijade wasn't being rude, just straightforward. You seem to have the basic idea down, so if you know how to use a for loop and an if statement, you should be able to do this.
To gain some understanding of what? You essentially asked for a complete "user's guide" to your assignment. If this is your assignment, I can guarantee that other assignments before this have used the print/println statement, so the "question" about "display" is a moot point (unless you need to show it in a dialog, but then you should say that, if that is the case). Now, you might, and I stress, might, not have had anything to do with loops yet, but I doubt that, so I must ask how much sleep you are getting at night to need this much sleep during your classes?
Last edited by masijade; Oct 9th, 2009 at 3:19 am.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.