Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > same method, different types of parameters

Reply
Thread Tools

same method, different types of parameters

 
 
san
Guest
Posts: n/a
 
      05-10-2005
Hi
Is it possible in Java like in C++ with templates, to write a Method
only once, for different types of parameter? Or do I have to write the
same methode for each parameter type I have?
Thanks for your help

 
Reply With Quote
 
 
 
 
Arnaud Berger
Guest
Posts: n/a
 
      05-10-2005
Hi,

What is possible is to specify a "larger" type :

say for basic types, if your method expects a type "long", you may call it
with type "int" or type "long" or type "short"

For Objects, if your method expects type "Object", you may call it with any
kind of object.

Apart from that, maybe Java 1.5 gives other possibilities that I ignore.

Regards,

Arnaud



"san" <(E-Mail Removed)> a écrit dans le message news:
(E-Mail Removed). com...
> Hi
> Is it possible in Java like in C++ with templates, to write a Method
> only once, for different types of parameter? Or do I have to write the
> same methode for each parameter type I have?
> Thanks for your help
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird issue, same code, same browser, two different apache servers,very different css bluebaron HTML 3 11-04-2009 07:13 PM
Returning different types based on input parameters George Sakkis Python 8 04-09-2009 06:10 PM
running same script on same data on two different machines -->different result Christopher Brewster Python 5 11-14-2008 08:19 PM
"Incompatible types" error though types are same generic type wdh3rd@gmail.com Java 3 04-15-2007 02:36 PM
same code produces different decimal symbol on different computers with same settings ASP General 2 12-29-2003 02:29 PM



Advertisments