aspose file tools*
The moose likes Performance and the fly likes How can be better? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "How can be better?" Watch "How can be better?" New topic
Author

How can be better?

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Hello,

I have some txt files with characters. In my java programm im reading these files and depending what character is in each place, show an image in JPanel. Im checking the characters simply by if, if else, else statments. My question is if there is a better way to do it, because are aprox 10-11 different images.

Thank you
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Use a HashMap and assign the key, value pairs by HashMap<Character, Image>
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Never used HashMap before, checked its API but did not understant how will be usefull in my programm. Any similar example please??
 
Consider Paul's rocket mass heater.
 
subject: How can be better?