Results 1 to 3 of 3
  1. #1
    Soxman04 is offline Member
    Join Date
    May 2011
    Rep Power

    Default Class as a Parameter.

    I have an ArrayList of the Interface GamePiece. I want to make a method that takes that ArrayList and returns all the object of a certain type. For example I could have the method return all of the GameBall objects (which implement GamePiece) in the ArrayList of GamePiece interfaces. I know how to use instanceof to check if an object is a certain class, but how would I have the method take a type of class as a parameter? :confused:

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power


    Use the getClass() method?

    Object (Java Platform SE 6)
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

Similar Threads

  1. Class<T> in method parameter
    By Onra in forum New To Java
    Replies: 4
    Last Post: 03-14-2011, 12:12 AM
  2. Passing final parameter from a class
    By ianyappy in forum New To Java
    Replies: 8
    Last Post: 12-02-2010, 07:06 PM
  3. Output parameter
    By xdzgor in forum JDBC
    Replies: 4
    Last Post: 11-19-2010, 08:03 AM
  4. Replies: 4
    Last Post: 06-18-2010, 10:08 AM
  5. Can a method take itself as parameter?
    By bukake in forum New To Java
    Replies: 10
    Last Post: 09-06-2008, 09:26 PM

Tags for this Thread

Posting Permissions

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