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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:30:57+00:00 2026-06-15T22:30:57+00:00

Hy I’m trying to bypass the process of making an arithmetical expression parser, cuz

  • 0

Hy I’m trying to bypass the process of making an arithmetical expression parser, cuz it’s a bit hart to build it from scratch and neither do i have the knowledge of writing one and we aren’t allowed to use other material for it.I came up with the idea of making a class that writes the code to an other class file thus bypassing the string-to-expression evaluation process.

public void PrintCode(String filename,String a) {
    PrintStream ps = null;
    try {
        ps = new PrintStream(filename);
    } catch (FileNotFoundException ex) {
        System.out.println("printWords: File open error: " + filename);
    }
        ps.println(i);
        ps.println(" public int a = "+a + ";\n\n" + " public int geta()\n    {\n    return a;\n    }" +"\n\n}");
        ps.close();

}

a is the given expression in String.The filename is for ex.: expression.java.
The other curious thing is that java can calculate these expressions in code , but there is no built-in function to evaluate given string type expressions.My problem is in fact that this code writing is saved after the program is finished and I need to reload the class after writing, or just load it after writing and then execute the geta() method to do the calculation.
The other thing is to restart the program from code somehow and continue from that point.
I am just a rookie to this we learned java for this semester only.. so if something is very wrong here , I apologize.And thanks in advance for any help!

EDIT: We didn’t learn about javascript so we can’t , or aren’t allowed to use it…sorry.

  • 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-06-15T22:30:58+00:00Added an answer on June 15, 2026 at 10:30 pm

    You can write bytecode from Java by using some of the libraries out there like ASM, but my suggestion is to use the ScriptEngine (Java 6+) interface to use JavaScript or some other sccripting language to execute your maths.

    I will update my blog with a post on this because I’m going to use it on a project of my own. I will comment back when the post will be available.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.