It's not a secret anymore!
The moose likes Beginning Java and the fly likes User Prompt Timer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "User Prompt Timer" Watch "User Prompt Timer" New topic

User Prompt Timer

podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
The following code sets a timer task in console.

But i want to implement a user prompt, to the code .. so the user can easily set the value of refreshing time ..

something like this ...

but the problem with this is i can't pass a String to the constructor ..

Is there a way to pass a int value, maybe with casting ? what is the correct way to do this ?

thanks a lot !
[ May 12, 2008: Message edited by: podonga poron ]
marc weber

Joined: Aug 31, 2004
Posts: 11343

You can't do it with casting, because a String is simply not an int.

But you can parse a String as an int using the parseInt method of the Integer class...

int myInt = Integer.parseInt(myString);

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
WOW !! now it works ! THANKS !!

i leave the code maybe someone find it useful ..

I agree. Here's the link:
subject: User Prompt Timer
It's not a secret anymore!