View Full Version : variable convertion
03-30-2004, 01:19 PM
how to convert from integer to string in java?
03-30-2004, 01:28 PM
int i = 1;
String s = Integer.toString(i);
03-30-2004, 01:36 PM
thank u 4 your reply.
but i have another question, if i want to view an integer number in a textfield, lets say i, must i convert it at first to string by using String s = Integer.toString(i), and then using the textField.setString(s) or there is another way?
03-30-2004, 05:04 PM
You can skip the part where you put it into a String variable:
03-31-2004, 02:33 AM
ok, if i have three textFields, one of them displays the multiply of the others. how to convert the string to integer? and how to get the text in the textField?
03-31-2004, 10:19 AM
I don't know how to get the text from the textfield because I don't use J2SE (I'm guessing textfield.getString() though), but to convert the string back to an int you use the Integer.parseInt(String s) method.
What you should really do is get the documentation for the classes you're using and read that. It probably has all the answers you need.
03-31-2004, 10:30 AM
sorry shmoove for bothering u, may be this question is the last one, where can i find the documentation for the classes?
03-31-2004, 12:45 PM
It's OK. It's no bother.
Here (http://java.sun.com/j2se/1.4.2/docs/index.html) you can find all the documentation. The API specs (http://java.sun.com/j2se/1.4.2/docs/api/index.html) will be the most useful (API & Language section -> Java 2 Platform API Specification), and in your place I'd maybe try a few of the tutorials (http://java.sun.com/j2se/1.4.2/docs/index.html#demos).
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.