isa Test

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • No One

    #1

    isa Test

    I've not done Java in a couple of years and I've been doing C# during
    that time, so I know I mixing my languages a bit. What I cannot
    remember how to do in Java is test an object for its type. In C# one
    uses the "isa" keyboard, but I can't find something like this in Java.
    Perhaps because I am having to use 1.2? The only thing I can think of
    is to compare the objectInstance. class.getName() and
    comparingObject .class.getName( ). This doesn't work for inheritance very
    well. Any pointers would be greatly appreciated.
  • Janwillem Borleffs

    #2
    Re: isa Test

    No One wrote:[color=blue]
    > I've not done Java in a couple of years and I've been doing C# during
    > that time, so I know I mixing my languages a bit. What I cannot
    > remember how to do in Java is test an object for its type. In C# one
    > uses the "isa" keyboard, but I can't find something like this in Java.
    > Perhaps because I am having to use 1.2? The only thing I can think of
    > is to compare the objectInstance. class.getName() and
    > comparingObject .class.getName( ). This doesn't work for inheritance
    > very well. Any pointers would be greatly appreciated.[/color]

    Use the "instanceof " keyword.

    JW



    Comment

    • No One

      #3
      Re: isa Test

      Janwillem Borleffs wrote:
      [color=blue]
      > No One wrote:
      >[color=green]
      >>I've not done Java in a couple of years and I've been doing C# during
      >>that time, so I know I mixing my languages a bit. What I cannot
      >>remember how to do in Java is test an object for its type. In C# one
      >>uses the "isa" keyboard, but I can't find something like this in Java.
      >>Perhaps because I am having to use 1.2? The only thing I can think of
      >>is to compare the objectInstance. class.getName() and
      >>comparingObje ct.class.getNam e(). This doesn't work for inheritance
      >>very well. Any pointers would be greatly appreciated.[/color]
      >
      >
      > Use the "instanceof " keyword.
      >
      > JW
      >
      >[/color]

      Thanks. I knew I was having a brain cramp.

      Comment

      Working...