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 7039475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:48:10+00:00 2026-05-28T01:48:10+00:00

Basically I’ve got an input string, my test string is ‘5 + 4’ and

  • 0

Basically I’ve got an input string, my test string is ‘5 + 4’ and I want to check character by character to create a list in the form [5,+,4], ie white spaces are ignored. Also, if my test string was ‘567+5-1’ it would output [567,+,5,-,1] by concatenating the numbers together. Unfortunately, it won’t let me do .add(inputChar) to my returnValue, saying symbol not found… any ideas?

import java.util.*;

public class CharacterArray {
    public List<String> splitToChar(String s) {
        List<String> returnValue = new LinkedList<String>();
        char[] chars = s.toCharArray();
        System.out.println(chars);
        int currentNumber;
        for (char inputChar : chars) {
            if (Character.isDigit(inputChar) == true) {
                currentNumber += inputChar;
            } else if (inputChar == '.') {
                currentNumber += inputChar;
            } else if (inputChar == '+') {
                returnValue.add(inputChar);
            } else if (inputChar == '-') {
                returnValue.add(inputChar);
            } else if (inputChar == '/') {
                returnValue.add(inputChar);
            } else if (inputChar == '*') {
                returnValue.add(inputChar);
            } else if (inputChar == '(') {
                returnValue.add(inputChar);
            } else if (inputChar == ')') {
                returnValue.add(inputChar);
            } else {
                System.out.println("Incorrect input symbol");
            }
        }
        return returnValue;
    }
}
  • 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-28T01:48:11+00:00Added an answer on May 28, 2026 at 1:48 am
    import java.util.*;
    
    public class CharacterArray {
        public List<String> splitToChar(String s) {
            List<String> returnValue = new LinkedList<String>();
            char[] chars = s.toCharArray();
            System.out.println(chars);
            String currentNumber = "";
            for (char inputChar : chars) {
                if (Character.isDigit(inputChar) == true) {
                    currentNumber += inputChar;
                } else if (inputChar == '.' ||
                        inputChar == '+' ||
                        inputChar == '-' ||
                        inputChar == '/' ||
                        inputChar == '*' ||
                        inputChar == '(' ||
                        inputChar == ')') {
                    if (currentNumber.length() > 0){
                        returnValue.add(currentNumber);
                    }
                    currentNumber = "";
                    returnValue.add(""+inputChar);
                }  else {
                    System.out.println("Incorrect input symbol");
                }
            }
            if (currentNumber.length() > 0){
                returnValue.add(currentNumber);
            }
            return returnValue;
        }
    }
    

    By the way, your currentNumber should be a String

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

Sidebar

Related Questions

Basically I want to create a user control in code behind, DataBind() it and
Basically I want to create a comment system where comments may have parents that
Basically what i want to say is can we decide among the list of
Basically what I want to do it this: a pdb file contains a location
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I have some code to check a specific directory to see if an
Basically I want to know how to set center alignment for a cell using
Basically, what I'm trying to create is a page of div tags, each has
Basically what I am doing is giving a user a list of terms via
Basically there is a file called 8puzzle.py and I want to import the file

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.