-1
Object[] possibilities = { "A:/", "B:/", "C:/" };
        String drive = (String) JOptionPane.showInputDialog(frame,
                "Pick a Drive", " ", JOptionPane.PLAIN_MESSAGE, null,
                possibilities, "C:/");

Is there a quicker way to make the options "A:/" to "Z:/" in possibilities without having to write every letter out?

Dobz
  • 1,213
  • 1
  • 14
  • 36
  • 1
    Why don't you just do it in a loop? – Rodrigo Sasaki Mar 28 '13 at 15:16
  • 6
    Listing A-Z would be invalid anyway, because not all Windows computers have all 26 possible drive letters in use. See [this previous question](http://stackoverflow.com/questions/51320/find-all-drive-letters-in-java) for how to list all drive letters that exist. – alroc Mar 28 '13 at 15:17

1 Answers1

3

If you just want to fill your array with all drive letters from A-Z, the following loop should work (assuming you declare poss with a length of 26 or greater):

for (int i = 0; i < 26; i++) {
    poss[i] = (char) ('A' + i) + ":/";
}
Octahedron
  • 893
  • 2
  • 16
  • 31