Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane and ArraySize not known

 
Maureen Charlton
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I was to use JOptionPane to get user input, with the opportunity to type exit when the user has finished entering their data, And I wanted to store the data they had input in an array would I have to use a dynamic array? (As I would need the array to grow in size to accommodate the number of user input items to initialise the size of the array).

Or is their an alternative?

 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to implement this yourself, it looks like you are on the right track. In that case, you don't need "import java.util.ArrayList". Alternatively, you can use ArrayList which already does this magic for you without any effort on your part.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic