Here you can find the source of multiply(Number n1, Number n2)
public static Number multiply(Number n1, Number n2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 The University of York. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /* w ww.ja va 2s. c o m*/ * Contributors: * Dimitrios Kolovos - initial API and implementation ******************************************************************************/ public class Main { public static Number multiply(Number n1, Number n2) { if (n1 instanceof Double || n2 instanceof Double) { return n1.doubleValue() * n2.doubleValue(); } else if (n1 instanceof Float || n2 instanceof Float) { return n1.floatValue() * n2.floatValue(); } else if (n1 instanceof Long || n2 instanceof Long) { return n1.longValue() * n2.longValue(); } else { return n1.intValue() * n2.intValue(); } } }