Results 1 to 4 of 4
- 01-19-2011, 06:08 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 30
- Rep Power
- 0
How to test whether the entered value is numeric or it contains some characters.
here is the code which i have written
Java Code:import java.util.Scanner; public class Assignment { public static void main(String[] args) { int row, column; int s=0; boolean found = false; String rollNumber; while (!found) { try { Scanner scan = new Scanner(System.in); System.out.print("Enter the size of the array s: "); String size = scan.next(); System.out.println("size is :" +size); System.out.println(); found = true; } catch (NumberFormatException nfe) { System.out.print("Please enter the number again in correct format:"); System.out.println(); } } // int[][] arr = new int[size][3]; } }
- 01-19-2011, 06:09 PM #2
What's your question? Where are you stuck? What have you tried?
See the APIs for String and Character for useful functions.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-19-2011, 06:21 PM #3
Member
- Join Date
- Jan 2011
- Posts
- 30
- Rep Power
- 0
got the answer.
- 01-19-2011, 06:25 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Similar Threads
-
Check if a string contains characters entered in a array
By roud9 in forum New To JavaReplies: 4Last Post: 11-05-2010, 10:43 AM -
How to test whether the entered value is numeric or it contains some characters.
By renu in forum New To JavaReplies: 13Last Post: 09-23-2010, 07:21 PM -
JXL, Numeric data issue
By only2008 in forum Java ServletReplies: 0Last Post: 02-27-2009, 11:36 AM -
get numeric value from a text field
By Lehane_9 in forum New To JavaReplies: 2Last Post: 06-14-2008, 03:19 AM -
Allowing only numeric values in a TextField
By Java Tip in forum Java TipReplies: 0Last Post: 03-01-2008, 10:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks