Users Pricing

forum

Home Forums Method argument of different types – MindStick

Method argument of different types

Lady Bird Johnson 2318 14 Oct 2013

I want to write method that would accept the parameter of types a.A or b.B. Currently it's implemented:


import a.A;

import b.B;
public void doSth(A arg) {
      SpecificClass.specificMethod(arg);
}
public void doSth(B arg)
{
      SpecificClass.specificMethod(arg);
}


I want to have one generic method "doSth" that use wildcards and accepts only a.A or b.B. Important information a.A and b.B aren't subtypes of each other. The only common type is java.lang.Object.

Any help?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md