Here you can find the source of divide(String type)
public static String divide(String type)
//package com.java2s; public class Main { public static String divide(String type) { try {//from ww w . j a va2 s . c om String[] operands = type.split("/"); double operand1 = Double.parseDouble(operands[0]); double operand2 = Double.parseDouble(operands[1]); double ans = operand1 / operand2; return Double.toString(ans); } catch (NumberFormatException e) { return type; } } }