Campbell Ritchie wrote:[Pedantic mode]There's no such thing as a 2-D array. Only a 1-D array, of 1-D arrays[/pedantic mode]
Don't know whether an array or array of arrays is more efficient. I would think the difference is probably slight, and you ought not to worry about such considerations unless there are signs of slow performance.
You appear only to be calling that method from your constructor, and you have correctly labelled the method private. Any advice that you can't call instance methods from a constructor is mistaken. Does every overloaded constructor call that method? I presume you haven't commented out the call to the method, as you have in your 1-argument constructor.
You have got far too much code which you haven't tried. You ought to write about 5 lines, compile and run the code, and see what sort of errors you suffer. Then you will know the code is actually running.
Add some debugging code inside that method. Start like this:Add some code to print out the names of the files you are opening, so you can verify they are correct.
You have got an empty catch block: put something "real" in it, egThe break; instruction is obscuring any errors and exceptions, so you don't find out what is going wrong.
Never, never write == true or == false. Both are poor style and very error-prone.
You ought not to start identifiers with _ (except in package names).
Thanks.
I could not get ex.printStackTrace() to work somehow, when trying to add the following lines to my exception handling block:
However, enabling the exceptions to be displayed resulted that the image files cannot be read, and, I still could not figure out
1. Why it can't read the GIF files from the directories?
2. How can I specify relative sub-directories (i.e. look for /img/01.GIF.. img/02.GIF up to img/52.gif. Not all of the image files exist at the moment?
Output
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\01.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\02.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\03.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\04.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\05.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\06.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\07.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\08.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\09.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\10.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\11.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\12.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\13.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\14.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\15.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\16.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\17.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\18.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\19.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\20.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\21.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\22.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\23.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\24.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\25.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\26.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\27.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\28.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\29.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\30.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\31.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\32.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\33.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\34.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\35.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\36.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\37.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\38.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\39.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\40.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\41.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\42.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\43.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\44.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\45.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\46.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\47.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\48.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\49.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\50.GIF
Can't read input file!
DEBUG: try to get filename
DEBUG: _filename = C:\Documents and Settings\Jon\workspace\Poker\src\img\51.GIF
Can't read input file!
[Ace of Clubs, Two of Clubs, Three of Clubs, Four of Clubs, Five of Clubs, Six of Clubs, Seven of Clubs, Eight of Clubs, Nine of Clubs, Ten of Clubs, Jack of Clubs, Queen of Clubs, King of Clubs, Ace of Diamonds, Two of Diamonds, Three of Diamonds, Four of Diamonds, Five of Diamonds, Six of Diamonds, Seven of Diamonds, Eight of Diamonds, Nine of Diamonds, Ten of Diamonds, Jack of Diamonds, Queen of Diamonds, King of Diamonds, Ace of Hearts, Two of Hearts, Three of Hearts, Four of Hearts, Five of Hearts, Six of Hearts, Seven of Hearts, Eight of Hearts, Nine of Hearts, Ten of Hearts, Jack of Hearts, Queen of Hearts, King of Hearts, Ace of Spades, Two of Spades, Three of Spades, Four of Spades, Five of Spades, Six of Spades, Seven of Spades, Eight of Spades, Nine of Spades, Ten of Spades, Jack of Spades, Queen of Spades, King of Spades]