Linked Questions

206 votes
14 answers
673k views

Converting a string to an integer on Android

How do I convert a string into an integer? I have a textbox I have the user enter a number into: EditText et = (EditText) findViewById(R.id.entry1); String hello = et.getText().toString(); And the ...
James Andrew's user avatar
  • 7,223
66 votes
11 answers
421k views

How do I use StringUtils in Java?

I'm a beginner in Java. I want to use StringUtils.replace but Eclipse outputs "StringUtils cannot be resolved". I tried import java.lang.*;, but it doesn't work.
Leo Jiang's user avatar
  • 25.3k
43 votes
5 answers
3k views

Convert string number to integer number [duplicate]

I have "1" as a string, and I would like to convert it to decimal, 1, as integer. I tried charAt(), but it returns 49, not 1 integer. So, what is required to convert the "1" string to 1 integer?
Chriss's user avatar
  • 995
16 votes
5 answers
46k views

Cannot convert String to Integer in Java [duplicate]

I have written a function to convert string to integer if ( data != null ) { int theValue = Integer.parseInt( data.trim(), 16 ); return theValue; } else return null;...
Ding's user avatar
  • 163
14 votes
1 answer
12k views

Get Value to Integer [duplicate]

How to get value of an object and store it in variable int? In string I do this: String k = s_extend.getValue().toString(); How about in int?
general_bearbrand's user avatar
10 votes
8 answers
35k views

atoi in java using charAt

I know that one solution to do this is the following: String tmp = "12345"; int result = 0; for (int i =0; i < tmp.length(); i++){ char digit = (char)(tmp.charAt(i) - '0'); ...
xonegirlz's user avatar
  • 8,939
10 votes
2 answers
12k views

How to convert InputStream to int [duplicate]

I have a txt file called "max_easy.txt" in /raw folder, in this file is written a number, in this case in "0"... I want a var which have 0 as a Int value, how do i do that? I guess this line gives me ...
xflea's user avatar
  • 177
8 votes
9 answers
137k views

How to set a date as input in java?

Is there any direct way to set a date to a variable but as an input? I mean that i don't know the date at design time, the user should give it. I tried the following code but it doesn't work: ...
user3159060's user avatar
8 votes
1 answer
5k views

method to convert from a string to an int [duplicate]

Possible Duplicate: Converting string to int in java I am trying to write a method that returns an int from a String variable. My method is: public int returnInt(String s) { }
logic101's user avatar
  • 211
6 votes
2 answers
2k views

Convert a string value into an int [duplicate]

How to convert string value into int? I am getting number format exception. String s = "20.00"; int i = (Integer.parseInt(s)); System.out.println(i); Result should be like i=20.
user2920003's user avatar
3 votes
6 answers
4k views

How to convert two strings to integers so math is correct?

I want the result no:5 but I get no:23 public class Assignment3 { public static void main(String args[]) { String str1 = "2"; String str2 = "3"; System.out.println("Result:" + (str1+...
arya's user avatar
  • 31
3 votes
4 answers
3k views

convert string to int in java

i have a string that has a int value in it. i just want to extract the int value from the string and print. String str="No. of Days : 365"; String daysWithSplChar = str.replaceAll("[a-z][A-Z]","")....
buttowski's user avatar
  • 4,827
3 votes
1 answer
638 views

Function with different parameter type in Delphi

How can I write two functions with the same name with different parameter types like this: public { Public declarations } function MsgW(const Msg:String):Integer; function MsgW(const ...
RepeatUntil's user avatar
  • 2,310
3 votes
2 answers
806 views

Quadratic Equation, cannot figure out syntax error

I am working on a school assignment. I am supposed to implement a class and supply the methods getSolution1 and getSolution2. However, I am having 2 issues with my code that I cannot figure out. ...
Jose M.'s user avatar
  • 2,280
3 votes
1 answer
331 views

Why is ""+ int flagged for Java in SonarQube

In Java I can convert an int to a string by "" + intValue. Sonarqube and sonarlint flag this as inappropriate. Why is this inappropriate. As far as I know Integer.toString(intValue) is more verbose ...
Hans's user avatar
  • 467

15 30 50 per page
1
2 3 4 5
12