I was wondering if there is a better implementation for converting the following VB6 snippets in Immediate window to Java:
? Format("002-", "")
-2
? Str("002-")
-2
My Java code scans through the string and if it sees a negative sign, converts the string to a negative integer, else positive. I would like to know if Java has a utility function which functions the same way as this.
A link to the Str function here.
Thanks!
I believe this is what you're looking for:
VB6 Java
--- -----
Str() Integer.toString (); # Convert integer to string
*** Integer.ParseInt (); # Convert string to integer
Format() String.Format ();
Here are some links:
Integer.ParseInt(): http://cs.fit.edu/~ryan/java/language/simple.html
String.Format(): http://www.xinotes.org/notes/note/1195/