|
-
Jan 17th, 2005, 04:28 PM
#1
Thread Starter
Frenzied Member
how to convert a string with operands to an integer
I guess it's obvious I've been working on a Calculator. I got stumped pretty soon into the project. How can I get the String entered and then convert it to an int when it has operands? I've tried so many different ways:
String s = textfield.getText();// were the text might be 1+1
int i = integer.parseInt(s);
I thought if there was no spaces between the 1 and + it would work...
The only sensible way I can think of is using a string tokenizer. But how would you append the operand to the numbers?
<Moderator added green checkmark in the first thread>
Last edited by NoteMe; Feb 17th, 2005 at 07:21 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|