Skip to main content

I have a simple question about strings.

4 replies [Last post]
jim_bow
Offline
Joined: 2008-05-10

I have a simple question about strings. How do you convert a String "123" into a Number?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
shagus
Offline
Joined: 2007-05-10

Hi. It is the same as in Java.
var a:String = "123";
var num:Number = java.lang.Integer.parseInt( a);

Shakir

jim_bow
Offline
Joined: 2008-05-10

Thank you for answering my question. I am new to Java and Javafx.

jim_bow
Offline
Joined: 2008-05-10

package notereader;
import java.lang.*;

var a:String = "123";

var num:Number = java.lang.Integer.parseInt( a);

"" Error in file Main.fx:13: undefined variable java in java.lang ""

alexsch
Offline
Joined: 2007-07-12

Do you use a compiler version of JavaFX Script?

It is better not to import whole java.lang.* package, only necessary classes like java.lang.System.