Here you can find the source of div(String[] X)
static public String div(String[] X)
//package com.java2s; //License from project: Apache License public class Main { static public String div(String[] X) { String[] newstring = new String[X.length]; String pop = ""; int i;//from ww w . j a v a 2 s .c o m int M = 0; newstring[M] = X[0]; for (i = 1; i < X.length; i++) { if (X[i] == "/") { double a = Double.parseDouble(X[i - 1]); double b = Double.parseDouble(X[i + 1]); if (X[i - 1].startsWith("+")) newstring[M] = "+" + Double.toString(a / b); else if (X[i + 1].startsWith("-") & X[i - 1].startsWith("-")) newstring[M] = "+" + Double.toString(a / b); else newstring[M] = Double.toString(a / b); X[i + 1] = Double.toString(a / b); i++; } else { if (X[i] != "/" || X[i + 1] != "/") M++; newstring[M] = X[i]; } } for (int ii = 0; ii < newstring.length; ii++) { if (newstring[ii] != null) pop += newstring[ii]; } return pop; } }