About 175,000 results
Open links in new tab
  1. How do I convert a String to an int in Java? - Stack Overflow

    With Java 11, there are several ways to convert an int to a String type: 1) Integer.parseInt() String str = "1234"; int result = Integer.parseInt(str); 2) Integer.valueOf() String str = "1234"; int result …

  2. Java - Convert integer to string - Stack Overflow

    int i = 1234; String str = Integer.toString(i); Returns a String object representing the specified integer. The argument is converted to signed decimal representation and returned as a string, …

  3. java - How to convert an integer value to string? - Stack Overflow

    Jan 30, 2011 · String s = String.valueOf(i); String s = Integer.toString(i); Another more concise way is: String s = "" + i; See it working online: ideone. This is particularly useful if the reason …

  4. java - How do I convert from int to String? - Stack Overflow

    Nov 5, 2010 · This is not a good way to convert an int to a string. Actually, you are not converting an int to a string, you are converting an int to a char. This will interpret the int as an ASCII …

  5. Most efficient way of converting String to Integer in java

    Jun 25, 2009 · static int toInt(java.lang.String str, int defaultValue) which allows you to specify a default value in the case of a failure. NumberUtils.toInt("1", 0) = 1 That's the best solution I've …

  6. Java: NumberFormatException in converting string to integer

    May 17, 2012 · Note that the parsing will fail if there are any white spaces in your string. You could either trim the string first by using the .trim method or else, do a replace all using the …

  7. java - What is the most efficient way to convert an int to a String ...

    May 31, 2017 · Look at the source code of the JRE and you'll probably see the difference. Or none. In fact the Strinv.valueOf(int foo) is implemented as follows:

  8. java - Converting String to Integers the safe way - Stack Overflow

    Jun 4, 2013 · I have a little method that amongst other things also converts a string into an integer. Since the string is a parameter of the method I want to make sure that that string is …

  9. java - convert string into int or double? - Stack Overflow

    Dec 13, 2012 · String num = input.nextLine(); int yourValue = Integer.parseInt(num); Parsing a double would use a similar method- Double.parseDouble() should do the trick. Alternatively, if …

  10. How to convert a Binary String to a base 10 integer in Java

    int foo = Integer.parseInt("1001", 2); works just fine if you are dealing with positive numbers but if you need to deal with signed numbers you may need to sign extend your string then convert to …

Refresh