+ 3
Guys how can i convert String into Integer in simple way ?
here is my code the result of integer should be 18. https://code.sololearn.com/cSVeHW8s3aAM/?ref=app
5 Answers
+ 17
public class Program
{
public static void main(String args[]) {
String s="2018";
int l=s.length();
int x=s.indexOf('0');
System.out.println(Integer.parseInt(s.substring(x+1,l))+1-1);
}
}
//use Integer.parseInt ()
+ 15
yes,thats correct
+ 4
String s ="2018";
int b=Integer.parseInt(s);
+ 3
in a particular variable
for example
int j=Integer.parseInt(s); //is that right.
+ 2
ok, thanks.