Java Programmers - Template?

Discussion in 'OT Technology' started by kcarlson78, Mar 11, 2003.

  1. kcarlson78

    kcarlson78 Meanwhile, Jesus continued to shake his head in ex

    Joined:
    Jun 27, 2002
    Messages:
    4,490
    Likes Received:
    0
    Location:
    Phoenix, AZ
    ok.. I know in C++ I can go

    Code:
    template <class E>
     E foo(E value, E anotherValue)
     {
        return (value + anotherValue); 
     }
    
    to create a function or class with no specific restrictions on data type..

    Does Java have a similar method???
     
  2. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    no java doesnt have templates, neither does it need it
     
  3. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    If you want no specific restriction on data type, you can just use Object class since every object in java is automatically inhereted from it
     
  4. kcarlson78

    kcarlson78 Meanwhile, Jesus continued to shake his head in ex

    Joined:
    Jun 27, 2002
    Messages:
    4,490
    Likes Received:
    0
    Location:
    Phoenix, AZ
    Ok.. how about operator overloads?
     

Share This Page