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

    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
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default

    Use the getClass() method?

    Object (Java Platform SE 6)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

Similar Threads

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