Results 1 to 3 of 3
Thread: do while (variable != type)
- 11-15-2010, 05:16 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
do while (variable != type)
Having a problem here. I wanted to make the segment of code repeat until a basic condition was met, type. As you can see below, I try just that, however, it won't let me create a condition based on type. Why? How do I get around this? I checked a couple resources on this and all I could find were examples based on a basic counter system.
Here's the code:
Java Code:do { String settingAccountNumber = JOptionPane.showInputDialog( null, "Please enter your account number: "); // Get input int i = Integer.parseInt( settingAccountNumber ); // Translate string to "int" } while ( i != int);
Basically, I'm trying to follow along with a project inside the book by creating a basic functioning ATM machine. The section that talks about while and do while doesn't say anything about basing them off type. I assumed either it was an advanced lesson or it didn't exist.
-
You would probably use a try/catch block here and catch the NumberFormatException for this to work well. Lots of examples of this on this forum and elsewhere.
- 11-15-2010, 05:29 AM #3
Member
- Join Date
- Nov 2010
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
How do I substitute any variable for a hardcoded variable
By Weazel Boy in forum New To JavaReplies: 11Last Post: 07-07-2010, 06:02 AM -
declare a private instance variable called ran of type random
By tinman in forum New To JavaReplies: 1Last Post: 12-09-2009, 12:57 AM -
using instanceof to get Object type and parent type?
By xcallmejudasx in forum New To JavaReplies: 2Last Post: 11-06-2008, 06:24 PM -
[SOLVED] Cast string type to int type
By GilaMonster in forum New To JavaReplies: 9Last Post: 09-17-2008, 10:43 AM -
[SOLVED] curiosity about String type variable
By monir6464 in forum Advanced JavaReplies: 1Last Post: 04-08-2008, 11:13 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks