Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void aMethod (MultipleObjects object){
- object.commonMethod();
- // Do some stuff here
- }
- interface MyInterface {
- void commonMethod();
- }
- class MyClass implements MyInterface {
- // implement `commonMethod()`
- }
- public void aMethod(MyInterface object) {
- ...
- object.commonMethod();
- ...
- }
- public void aMethod(SomeInterface obj) {
- obj.commonMethod();
- // ...
- }
- public interface SomeInterface {
- public void commonMethod();
- }
- interface CommonMethodHaver {
- void commonMethod();
- }
- class Class1 implements CommonMethodHaver {
- yadda yadda yadda;
- void commonMethod() {
- do class1-specific stuff here;
- }
- }
- ...
- public void aMethod(CommonMethodHaver cmh) {
- cmh.commonMethod();
- // Do some stuff here
- }
- public void aMethod(Object... object) {
- if(object==null)
- {
- //whatever you want to do if no parameters are entered.
- return;
- }
- for (Object o : object) {
- if (o == null) {
- continue; //what to do if null entered
- }
- if (o instanceof Integer) {
- //whatever you want to do if it is an Integer
- }
- else if(o instanceof Double)
- {
- //whatever you want to do if it is a Double
- }
- else if(o instanceof Character)
- {
- //whatever you want to do if it is a Character
- }
- //and so on
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement