Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

string to int

 
Andrew Lit
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
it is very urgent. i've forgotten method that converts string to int. plz remind me. would be very appreciated.
thanks
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Integer.parseInt()
 
Volodymyr Shram
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andrew Lit:
hi,
it is very urgent. i've forgotten method that converts string to int. plz remind me. would be very appreciated.
thanks

 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If performance is an issue, the first solution should be chosen.
W.
 
kumard
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//-----------------------------
public void test1() {
String i = "5";
timer.reset();
for(int j = 0; j < loop; j++) {
int k = Integer.valueOf(i).intValue();
}
timer.print("intValue");
}
//-----------------------------
public void test2() {
String i = "5";
timer.reset();
for(int j = 0; j < loop; j++) {
int k = Integer.parseInt(i);
}
timer.print("parseInt");
}
my test shows
intValue: 173.5
parseInt: 121.9
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic