Results 1 to 7 of 7

Thread: Anonymous revised

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Anonymous revised

    Can I do like
    Code:
    Cell cell = new Cell() { public Cell() { this.setColumnSpan(3); }};
    Or is there any another solution? Provided I only have a blank constructor (default).

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Anonymous revised

    No, you can't... The Java compiler will start a party
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Anonymous revised

    I would try it and see. You can do the exact same thing with actionlisteners so I don't see why not. Anynonymous classes are allowed.

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Anonymous revised

    Quote Originally Posted by System_Error
    I would try it and see. You can do the exact same thing with actionlisteners so I don't see why not. Anynonymous classes are allowed.
    That's an interface, there is a big difference.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Anonymous revised

    Anonymous classes are allowed. If you think otherwise then you need a java certification book.

    Neb, it seems that for an annoymous class to work you cannot have a named variable, so this should work:

    new Cell() { public Cell() { this.setColumnSpan(3); }};
    So you can't have a name and theirs no way to refer to them. Probably not what you are looking for, but anonymous classes ARE legal.

  6. #6
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: Anonymous revised

    Quote Originally Posted by ComputerJy
    That's an interface, there is a big difference.
    No, that's an inner class implementing an interface.. there's a big difference.

  7. #7
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Anonymous revised

    Quote Originally Posted by System_Error
    No, that's an inner class implementing an interface.. there's a big difference.
    I'm good with that
    But implementing A CONSTRUCTOR -- NO WAY
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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