Here you can find the source of divide(Object o1, Object o2, String type)
public static Object divide(Object o1, Object o2, String type)
//package com.java2s; //License from project: Apache License public class Main { public static Object divide(Object o1, Object o2, String type) { if (type.equalsIgnoreCase("double") || type.equalsIgnoreCase("float")) { return add((Double) o1, (Double) o2); } else if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("long")) { return add((Long) o1, (Long) o2); } else if (type.equalsIgnoreCase("string")) { return ""; } else if (type.equalsIgnoreCase("date")) { return null; }/*ww w . j a v a 2 s . c o m*/ return null; } private static Long divide(Long o1, Long o2) { return o1 / o2; } private static Double divide(Double o1, Double o2) { return o1 / o2; } public static Object add(Object o1, Object o2, String type) { if (type.equalsIgnoreCase("double") || type.equals("float")) { return add((Double) o1, (Double) o2); } else if (type.equalsIgnoreCase("int") || type.equalsIgnoreCase("integer") || type.equalsIgnoreCase("long")) { return add((Long) o1, (Long) o2); } else if (type.equalsIgnoreCase("string")) { return ((String) o1).concat((String) o2); } else if (type.equalsIgnoreCase("date")) { return null; } return null; } private static Long add(Long o1, Long o2) { return o1 + o2; } private static Double add(Double o1, Double o2) { return o1 + o2; } }