|
-
error variable not initialized
import java.io.*;
public class PP1 {
public static int getGoodInt(BufferedReader kbd) {
int n;
boolean ok=false;
while ( !(ok==true)) {
try {
BufferedReader br = new BufferedReader(
new InputStreamReader(System.in));
String instring = br.readLine();
n = Integer.parseInt(instring);
ok=true;
}
catch (IOException e)
{
System.out.println("Input/output error");
}
catch (NumberFormatException e)
{
System.out.print(n +" is not an int -- try again:");
//error variable n might not have been initialized
}
}
return n; // same thing as the other
}
}
help
thanks
Similar Threads
-
Replies: 2
Last Post: 02-22-2005, 04:33 PM
-
By raj74 in forum ASP.NET
Replies: 1
Last Post: 12-09-2002, 03:27 PM
-
By Elmosca in forum ASP.NET
Replies: 1
Last Post: 09-16-2002, 09:53 AM
-
By Kevin Baker in forum .NET
Replies: 3
Last Post: 10-01-2001, 11:34 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks