String myString = "1234";
int foo = Integer.parseInt(myString);

If you look at the Java documentation you'll notice the "catch" is that this function can throw a NumberFormatException, which you can handle:

int foo;
try {
   foo = Integer.parseInt(myString);
}
catch (NumberFormatException e) {
   foo = 0;
}

(This treatment defaults a malformed number to 0, but you can do something else if you like.)

Alternatively, you can use an Ints method from the Guava library, which in combination with Java 8's Optional, makes for a powerful and concise way to convert a string into an int:

import com.google.common.primitives.Ints;

int foo = Optional.ofNullable(myString)
 .map(Ints::tryParse)
 .orElse(0)
Answer from Rob Hruska on Stack Overflow
๐ŸŒ
Text Compare
textcompare.io โ€บ string-to-int-converter
String to INT Converter Online
String to Integer Converter is a tool that makes the conversion of textual data (strings) into integer values easier.
๐ŸŒ
Online String Tools
onlinestringtools.com โ€บ convert-decimal-to-string
Convert Decimal to a String โ€“ Online String Tools
Free online decimal to string converter. Just load your decimal and it will automatically get converted to a string. There are no intrusive ads, popups or nonsense, just a decimal to string converter. Load a decimal, get a string.
๐ŸŒ
Browserling
browserling.com โ€บ tools โ€บ text-to-decimal
Text to Decimal Converter - Convert Text to Decimal String - Online - Browserling Web Developer Tools
For example, if you're writing a web application that transfers messages using a simple non-binary text protocol, then it may get tricky to transfer multi-byte characters (such as Unicode symbols and emojis). With this utility, you can convert any text, Unicode glyphs, and multi-byte strings into decimal numbers (or integers).
๐ŸŒ
Convert String
convertstring.com
Convert String - Online String Conversion tools
Convert String offers resources for converting strings between formats. If you need a fast free online tool for applying common string functions or string manipulation routines then you are in the right place!
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ csharp โ€บ programming-guide โ€บ types โ€บ how-to-convert-a-string-to-a-number
How to convert a string to a number - C# | Microsoft Learn
Download Microsoft Edge More info about Internet Explorer and Microsoft Edge ... Access to this page requires authorization. You can try signing in or changing directories. Access to this page requires authorization. You can try changing directories. ... You convert a string to a number by calling the Parse or TryParse method found on numeric types (int, long, double, and so on), or by using methods in the System.Convert class.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ convert-string-to-int-in-c
Convert String to int in C - GeeksforGeeks
July 23, 2025 - The atoi() function in C takes a character array or string literal as an argument and returns corresponding value as integer. It is defined in the <stdlib.h> header file. If you observe the name atoi() a little closer, you will find out that ...
๐ŸŒ
Simonv
simonv.fr โ€บ TypesConvert
Types converter
Independently of the input format, conversion is limited to 64 bits. ... Conversion in SINT8 type of the input value results in overflow. The displayed value is the result of the overflow. Note that overflow of signed 8-bits integer is undefined and therefore the result given here is for ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ convert-string-to-integer-in-python
Convert String to Int in Python - GeeksforGeeks
The simplest way to convert a string to an integer in Python is by using the int() function.
Published ย  September 11, 2025
Find elsewhere
๐ŸŒ
PhraseFix
phrasefix.com โ€บ tools โ€บ decimal-to-string
Decimal to String Converter - PhraseFix
Free online tool that converts decimal to string. Simply enter the decimal and the online tool will convert it into text.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ JavaScript โ€บ Reference โ€บ Global_Objects โ€บ parseInt
parseInt() - JavaScript | MDN
If not NaN, the return value will be the integer that is the first argument taken as a number in the specified radix. (For example, a radix of 10 converts from a decimal number, 8 converts from octal, 16 from hexadecimal, and so on.) The radix argument is converted to a number. If it's unprovided, or if the value becomes 0, NaN or Infinity (undefined is coerced to NaN), JavaScript assumes the following: If the input string, with leading whitespace and possible +/- signs removed, begins with 0x or 0X (a zero, followed by lowercase or uppercase X), radix is assumed to be 16 and the rest of the string is parsed as a hexadecimal number.
๐ŸŒ
Online String Tools
onlinestringtools.com โ€บ convert-string-to-decimal
Convert a String to Decimal โ€“ Online String Tools
Free online string to decimal converter. Just load your string and it will automatically get converted to a decimal string. There are no intrusive ads, popups or nonsense, just a string to decimal converter. Load a string, get its decimal representation.
๐ŸŒ
SCADACore
scadacore.com โ€บ home โ€บ tools โ€บ programming calculators โ€บ online hex converter
Online Hex Converter - Bytes, Ints, Floats, Significance, Endians - SCADACore
April 8, 2021 - Online Hex Converter This is a free online hex converter that converts hex values into bytes, ints, and floats of different bit significance. With millions of different sensors and devices that will be connected to the cloud for IIoT, determining the
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ java-string-to-int-how-to-convert-a-string-to-an-integer
Java String to Int โ€“ How to Convert a String to an Integer
November 23, 2020 - This method returns the string as a primitive type int. If the string does not contain a valid integer then it will throw a NumberFormatException. So, every time we convert a string to an int, we need to take care of this exception by placing the code inside the try-catch block.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ java โ€บ how do i convert a string to an int in java?
How do I convert a String to an int in Java? | Sentry
We use int number; instead of Integer number to declare our variable that will hold the result, and we changed both instances of valueOf to parseInt. The output and other functionality are otherwise identical. class Main { public static void main(String[] args) { String validString = "123"; String invalidString = "123x"; int number; try { number = Integer.parseInt(validString); System.out.println("Converted integer: " + number); number = Integer.parseInt(invalidString); System.out.println("Converted integer: " + number); } catch (NumberFormatException e) { System.out.println("Invalid integer input"); } } }
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ how-to-convert-a-string-into-an-integer-in-python
How to Convert a String Into an Integer in Python | DataCamp
November 24, 2024 - This function takes a string as input and returns its integer representation, provided the string represents a valid whole number. # Convert a string to an integer numeric_string = "42" converted_integer = int(numeric_string) print(converted_integer) # Output: 42
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-convert-string-to-int-in-java
String to int in Java - GeeksforGeeks
Note: valueOf() method uses parseInt() internally to convert to integer. ... // Java ProgramConvert String to int // using Integer.valueOf() Method public class StringToInt { public static void main(String[] args) { // Convert String to Integer ...
Published ย  July 23, 2025
๐ŸŒ
Browserling
browserling.com โ€บ tools โ€บ decimal-to-text
Decimal to Text Converter - Convert Decimal to String - Online - Browserling Web Developer Tools
Useful, free online tool that converts decimal integer values to plain text. No ads, nonsense, or garbage, just a dec to text converter. Press a button โ€“ get the result.
๐ŸŒ
Cherry Servers
cherryservers.com โ€บ home โ€บ blog โ€บ cloud computing โ€บ how to convert string to int in python | comprehensive guide
How to Convert String to int in Python? | Cherry Servers
November 7, 2025 - Discover how Caxita, an online ... and 24/7 technical support. ... We can convert an integer value to a string value using the str() function....