I am new to Java, coming from VB.NET. In VB it is rather simple to convert from any single datatype to another by doing a ctype(). I am trying to convert a string to an integer using java. I know that i can conver types such as a float to an integer using: int blah = (int) float but i receive an error when trying to do this to a string...any words of advice are welcome.
The static method java.lang.Integer.parseInt() is one way to do this:
Likewise, there's a parseDouble() in java.lang.Double, a parseFloat() in java.lang.Float(), etc. These methods report failure -- i.e., a String that doesn't look like a valid number -- by throwing NumberFormatException; a proper program has to catch and deal with that error.