Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By JosAH

Thread: splitting strings.

  1. #1
    Bimz is offline Member
    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    0

    Default splitting strings.

    Ive been looking on the internet but i dont understand how to use the split string for what im doing. I have a string value which would look something like this "5 + 3" depending on the user's input. That string is then outputted into a JTextField. When i press a button the equation should solve itself, so then once the button is clicked the JTextField would output the solved equation. Can you show me how to do this using the splitting strings technique?

    much appreciated, Bimz :)

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default Re: splitting strings.

    Check my blogs on this forum: one of them discusses the Javascript interpreter that can evaluate your expressions; the other on is about compilers that can also evaluate your expressions. Simply splitting those Strings is not going to do the job. If I remember well you concentrated on just the view part of your calculator without paying any attention to the controller part of it; now you bounced into this problem ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Bimz is offline Member
    Join Date
    Aug 2011
    Posts
    31
    Rep Power
    0

    Default Re: splitting strings.

    yeah lol ive finished everything exept the equals button :) kinda stuck, thanks for the help.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default Re: splitting strings.

    Quote Originally Posted by Bimz View Post
    yeah lol ive finished everything exept the equals button :) kinda stuck, thanks for the help.
    You're welcome of course; take the easy route and let the embedded Javascript engine do the nasty work (read my blog and copy the code from it). You can even extend your calculator with functions (sin, log etc) for free if you use that interpreter.

    kind regards,

    Jos
    Fubarable likes this.
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Splitting number
    By cshoya in forum New To Java
    Replies: 2
    Last Post: 06-06-2011, 03:23 AM
  2. Splitting Strings
    By punk in forum New To Java
    Replies: 3
    Last Post: 04-06-2011, 08:49 AM
  3. Splitting
    By marksey07 in forum New To Java
    Replies: 2
    Last Post: 01-05-2011, 01:55 AM
  4. String Splitting
    By A.M.S in forum New To Java
    Replies: 1
    Last Post: 12-04-2009, 07:17 AM
  5. Array splitting
    By Lunarion in forum New To Java
    Replies: 3
    Last Post: 04-17-2009, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •