Results 1 to 3 of 3

Thread: Equivalent of Struct [resolved]

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    Equivalent of Struct [resolved]

    This doesn't work:
    Code:
    private class A
    {
        InetAddress i;
    }
    Vector v = new Vector();
    System.out.println(v.elementAt(0).i);
    I'm adding only A's to v, so why can't I do that?
    Last edited by filburt1; Oct 26th, 2001 at 03:00 PM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Code:
    private class A
    {
        InetAddress i;
    }
    Vector v = new Vector();
    System.out.println(((A)v.elementAt(0)).i);
    Vectors hold Objects, so you have to cast back to the original datatype.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    Got it by casting like you suggested.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width