2017-02-18 23:43:07 -06:00
|
|
|
// Author: Rodney Shaghoulian
|
2018-07-27 16:45:56 -07:00
|
|
|
// Github: github.com/RodneyShag
|
|
|
|
|
// HackerRank: hackerrank.com/RodneyShag
|
2017-02-18 23:43:07 -06:00
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
2017-02-21 00:05:09 -06:00
|
|
|
class Printer {
|
|
|
|
|
public <T> void printArray(T[] array) {
|
2017-02-18 23:43:07 -06:00
|
|
|
for (T item : array) {
|
|
|
|
|
System.out.println(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Solution {
|
2017-04-05 18:42:35 -05:00
|
|
|
public static void main(String args[]) {
|
|
|
|
|
Printer myPrinter = new Printer();
|
|
|
|
|
Integer[] intArray = { 1, 2, 3 };
|
2017-02-18 23:43:07 -06:00
|
|
|
String[] stringArray = {"Hello", "World"};
|
|
|
|
|
myPrinter.printArray(intArray);
|
|
|
|
|
myPrinter.printArray(stringArray);
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (Method method : Printer.class.getDeclaredMethods()) {
|
|
|
|
|
String name = method.getName();
|
2017-02-24 00:24:47 -06:00
|
|
|
if (name.equals("printArray")) {
|
2017-02-18 23:43:07 -06:00
|
|
|
count++;
|
2017-02-24 00:24:47 -06:00
|
|
|
}
|
2017-02-18 23:43:07 -06:00
|
|
|
}
|
2017-02-24 00:24:47 -06:00
|
|
|
if (count > 1) {
|
|
|
|
|
System.out.println("Method overloading is not allowed!");
|
|
|
|
|
}
|
2017-02-18 23:43:07 -06:00
|
|
|
}
|
|
|
|
|
}
|