Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:59:08+00:00 2026-05-15T22:59:08+00:00

i am confused on why it doest not split the string? my array of

  • 0

i am confused on why it doest not split the string? my array of string exp does not contain anything when i debug it is the split wrong?what i am trying to do is to split a very simple expression like 1+2+3 and then parse the values, doing a calculator.

EDIT
hi, why i am splitting on each character is because i am doing a calculator, and have read something about converting infix to postfix,so i need to split the string and then loop through each of the string and do the checking as shown below,however when i debug it shows the exp[] is empty

For each token in turn in the input infix expression:

    * If the token is an operand, append it to the postfix output.
    * If the token is an operator A then:
          o While there is an operator B of higher or equal precidence than A at the top of the stack, pop B off the stack and append it to the output.
          o Push A onto the stack.
    * If the token is an opening bracket, then push it onto the stack.
    * If the token is a closing bracket:
          o Pop operators off the stack and append them to the output, until the operator at the top of the stack is a opening bracket.
          o Pop the opening bracket off the stack.

When all the tokens have been read:

    * While there are still operator tokens in the stack:
          o Pop the operator on the top of the stack, and append it to the output.


   // the main class
public class Main {


    public static void main(String[] args) {
       calcExpChecker calc = new calcExpChecker("1+2+3+4");
       calc.legitExp();
       calc.displayPostfix();
    }

}
//the class
package javaapplication4;
import java.util.*;


public class calcExpChecker {


    private String originalExp; // the orginal display passed
    private boolean isItLegitExp; // the whole expression is it legit
    private boolean isItBlank; // is the display blank?
    private StringBuilder expression = new StringBuilder(50);
    private Stack stack = new Stack();//stack for making a postfix string

    calcExpChecker(String original)
    {
        originalExp = original;
    }

     //check for blank expression
    public void isitBlank()
    {
        if(originalExp.equals(""))
        {
            isItBlank = true;
        }
        else
        {
            isItBlank = false;
        }

    }

    //check for extra operators
    public void legitExp()
    {
      String[] exp = originalExp.split(".");
      for(int i = 0 ; i < exp.length ; i++)
      {
          if(exp[i].matches("[0-9]"))
          {
              expression.append(exp[i]);
          }
          else if(exp[i].matches("[+]"))
          {
             if(stack.empty())
             {
                 stack.push(exp[i]);
             }
             else
             {
                 while(stack.peek().equals("+"))
                 {
                    expression.append(stack.pop());
                 }
                 stack.push(exp[i]);
             }
          }
        if (!stack.empty())
        {
            expression.append(stack.pop());
        }
      }

    }

    public void displayPostfix()
    {
        System.out.print(expression.toString());
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:59:09+00:00Added an answer on May 15, 2026 at 10:59 pm

    If you make every character a delimiter, what is between them? Nothing

    e.g.,
    1+2+3+4
    is 1 a delimiter? yes, ok, capture everything between it and the next delimiter. Next delimiter? +. Nothing captured. Next delimiter? 2. etc etc

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The app delegate is really the start of the application… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer The ellipsis ..., in a function prototype, is used to… May 16, 2026 at 12:43 pm
  • Editorial Team
    Editorial Team added an answer You may want to try the following: SELECT CONCAT(title, '… May 16, 2026 at 12:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm new to the entity framework and I'm really confused about how savechanges works.
I'm creating my first web application and I'm really confused as to what technology
In prototypejs, why does the following code remove the matching divs from the #test
I am confused about the BinarySearch method of List<T> in case when the item
Possible Duplicate: Why is my return type meaningless? Hi, I'm confused about a particular
I am trying to learn how to use BDD for our development process and
Given the following declaration: <Extension()> Public Function ToJSON(ByVal target As Object) As String Dim
I am confused about garbage collection process on objects. object A = new object();
I am confused about the exact limitations on folder names in an ISO 9660
I am confused about how to set this up using Cake's conventions. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.