2 Replies Latest reply: Dec 12, 2009 4:27 AM by 807580 RSS

    Array with multiple data types.

    807580
      Is there any way to create a multi-dimentional array with each dimension storing data of different data types? For instance, i need to store IP address (string type), port (int type), host name ( string type) in a single Multi-Dimentional array. Thanks in advance.
        • 1. Re: Array with multiple data types.
          807580
          sowndar wrote:
          Is there any way to create a multi-dimentional array with each dimension storing data of different data types? For instance, i need to store IP address (string type), port (int type), host name ( string type) in a single Multi-Dimentional array.
          Yes, the answer is: just don't do it. This is a bad design and will break easily. The better solution is to create a class that holds String, int, and String, and then create a 1-D array (or perhaps better the more flexible ArrayList) of objects of this class.

          Best of luck and hope this helps!
          • 2. Re: Array with multiple data types.
            807580
            +1. As soon as you start giving different semantic meanings to different elements of an array, it's time for a class.