I have a question about trying to get an array list to print the same items over and over again. What I need is the output to look like this
Item A : xyz Item B : abc
Item A : abc Item B : xyz
Item A : yui Item B : qwe
Etc...
Item A and B are from a user input in to an array list.
Here is the code that I have so far
Scanner in = new Scanner(jTextField1.getText());
while (in.hasNextDouble())
{
min.add(in.nextDouble());
}
Scanner ine = new Scanner(jTextField2.getText());
while (ine.hasNextDouble())
{
pay.add(ine.nextDouble());
}
for (double earnings : pay)
for (double element : min)
{
jTextArea1.setText("Minutes = " + element + " ");
jTextArea1.append("Pay = $" + earnings + " \n");
}
This code just replaces the text each time I enter it. I have tried to JTextArea1.append on both TextArea items and it keeps adding the previous user inputs rather than a new line for the new input. I tried a while loop to no success either... I'm sure there is something simple that I am missing here, but as someone that is in the process of learning code I'm not seeing it. Any help would be much appreciated!

New Topic/Question
Reply



MultiQuote



|