java - why did it not split? -
I am confused why this string does not divide? Nothing contained in my array of string app when I debug, is this partition wrong? What I'm trying to do, is to divide a very simple expression like 1 + 2 + 3 and then make a calculator to parse the values.
Edit Hello, why am I dividing each character, because I am doing a calculator, and have read something about conifting infix into postfix, So I need to split the string, each of the strings and like a check shown below, but when I debug it shows that [] is empty
input input Every penis in expression For: * If the token is an operand, add it to postfix output. * If the token is an operator a: o while on the top of the stack, an operator B, A or highest equivalent to A, pop B on the stack and add it to the output. Push to O Stack. * If the token is an opening bracket, press it on the stack. * If the token is a closing bracket, then opaque closes the operators on the stack and adds them to the output, as long as the operator does not have an opening bracket at the top of the stack. Close the opening bracket with a heap when all tokens are read: * The stack still has operator tokens: pop the operator at the top of the O stack, and add it to the output. // main square public square main {public static zero main (string [] args) {calcExpChecker calc = new calcExpChecker ("1 + 2 + 3 + 4"); Calc.legitExp (); Calc.displayPostfix (); }} // class package javaapplication4; Import java.util. *; Public class calcExpChecker {Private string originalExp; // Basic Boolean Passed Display is ITLegitExp; // Full Expression It's legal private boolean ITBlank; // Is the display empty? Private stringbilder expression = new string builder (50); Private stack stack = new stack (); // Stuff (string origin) to make postfix string cyluxx packer {originalExp = original; } // Check for blank expression; Public Zero isitBlank () {if (Original Exp.equals ("")) {isItBlank = true; } And {isItBlank = false; }} // Check for additional operators: Public Zero Legal (APP) (string [] exp = originalExp.split ("."); For (int i = 0; i
If you make each character a delimiter Their b What's the matter? Nothing. For example, 1 + 2 + 3 + 4 1 is the delimiter? Yes, okay, capture everything between this and the next delimiter, next delimiter? Also did not get the next delimiter? 2. Etc. etc
Comments
Post a Comment