File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Is there better way to implement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Is there better way to implement?" Watch "Is there better way to implement?" New topic

Is there better way to implement?

krishnapriya varma

Joined: Nov 07, 2007
Posts: 2

I would like to know whether what i have done is the best way to implement:
I have a method that takes a Date value and a String value as parameters. I have a set of dates and the string value pairs. I have stored it in a multidimentional array, and while passing to method, i have converted the String to Date. Here is my code:

Can you please tell me if there is a better way to implement this? Is there any other Collection that i can use?

Thanks a lot in advance!!!
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

I would change from using a multi-dimensional array to using an array of Parameter objects, which have a date and String property (though it might be a Date andInteger, since the String value looks like its going to be a number)). This saves you the headache of managing a multi-dimensional array, means you don't have to worry about the date format and stops someone changing string values in your array causing the application to crash.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Is there better way to implement?
jQuery in Action, 3rd edition