Results 1 to 3 of 3
- 08-03-2012, 08:07 AM #1
Member
- Join Date
- Aug 2012
- Posts
- 11
- Rep Power
- 0
boolean isDigit() inside if statement
Im including the entire method as I'm sure improvements can be made, but my problem is with an if statement containing the boolean isDigit(). Even when the boolean evaluates to false the statements following are run. The method runs through an array and appends all of the numerical values to a StringBuilder.
Java Code:public static String extractNumbers(String line) { StringBuilder str = new StringBuilder(); for (char i: line.toCharArray()) { if (Character.isDigit(i)); //also tried (Character.isDigit(i) == true) { str.append(i); System.out.println(Character.isDigit(i)); } } return str.toString(); }
- 08-03-2012, 08:15 AM #2
Student
- Join Date
- Jul 2012
- Location
- United States
- Posts
- 328
- Rep Power
- 1
Re: boolean isDigit() inside if statement
"Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill
- 08-03-2012, 08:22 AM #3
Member
- Join Date
- Aug 2012
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
Boolean.True and Boolean.False, why do some people use these?
By Pojahn_M in forum New To JavaReplies: 3Last Post: 09-13-2011, 12:01 AM -
Strange behaviour of If statement inside an Array derived from ResultSet
By matthelazy in forum New To JavaReplies: 3Last Post: 08-08-2011, 05:07 PM -
"boolean isDigit(char ch)" not working...please help
By cc11rocks in forum New To JavaReplies: 7Last Post: 02-06-2011, 01:40 AM -
Return Statement and Boolean Help
By GhostShaman in forum New To JavaReplies: 8Last Post: 03-09-2010, 11:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks