problem in overwrite using Generics

Discussion in 'Java' started by SantaJava@gmail.com, Jan 30, 2007.

  1. Guest

    package jp.co.nec.rfidmgr.epcis;

    import java.util.List;
    import java.util.Map;

    public class T {
    public void temp(List<String> str) {

    }

    public void temp(List<Integer> str) {

    }

    public void temp(List<Map<Integer,String>> str) {

    }
    }

    error:
    Duplicate method temp(List<String>) in type T T.java
    Duplicate method temp(List<Integer>) in type T T.java
    Duplicate method temp(List<Map<Integer,String>>) in type T T.java

    how can i overwrite a method using generics
    , Jan 30, 2007
    #1
    1. Advertising

  2. Daniel Pitts Guest

    On Jan 29, 8:23 pm, "" <> wrote:
    > package jp.co.nec.rfidmgr.epcis;
    >
    > import java.util.List;
    > import java.util.Map;
    >
    > public class T {
    > public void temp(List<String> str) {
    >
    > }
    >
    > public void temp(List<Integer> str) {
    >
    > }
    >
    > public void temp(List<Map<Integer,String>> str) {
    >
    > }
    >
    > }
    >
    > error:
    > Duplicate method temp(List<String>) in type T T.java
    > Duplicate method temp(List<Integer>) in type T T.java
    > Duplicate method temp(List<Map<Integer,String>>) in type T T.java
    >
    > how can i overwrite a method using generics

    The problem is, you can't.
    Unles you name temp something else, and in this case, there really
    isn't any reason not to.

    import java.util.List;
    import java.util.Map;

    public class T {

    public void tempString(List<String> str) {
    }

    public void tempInteger(List<Integer> str) {
    }

    public void tempMap(List<Map<String, Integer>> str) {
    }
    }
    Daniel Pitts, Jan 30, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Um9iZXJ0?=

    Deployment in 2.0 - How To Not Overwrite web.config

    =?Utf-8?B?Um9iZXJ0?=, Nov 2, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    4,432
    Juan T. Llibre
    Nov 3, 2005
  2. Juergen Berchtel
    Replies:
    1
    Views:
    5,968
    John C. Bollinger
    May 20, 2005
  3. Replies:
    0
    Views:
    297
  4. Soul
    Replies:
    0
    Views:
    503
  5. Replies:
    2
    Views:
    94
    Henry
    Feb 5, 2008
Loading...

Share This Page