Click here to Skip to main content
15,899,474 members

Comments by radhikay (Top 16 by date)

radhikay 28-Dec-19 2:20am View    
In my question, both statements have Pattern.matches but why the second statement is false.? Both 'm' and 'n' are present in [amn]
radhikay 22-Sep-19 5:19am View    
I will try this . thank you
radhikay 22-Sep-19 4:38am View    
I am having problem with spaces at the beginning of sentence. so trim() method will help me.

Please tell me the solution, I am not getting idea
radhikay 22-Sep-19 4:38am View    
Deleted
I am having problem with spaces at the beginning of sentence. so trim() method will help me.

Please tell me the solution, I am not getting idea
radhikay 22-Sep-19 3:52am View    
I got a solution to remove the spaces using trim() method. - which gives me correct answer for case 2

But as per your solution "only start a new count when a non-space is encountered" I have already used that logic as below
if(text.charAt(i)==' ' && text.charAt(i+1)!=' ')
the count gets incremented only when the current index in space and next index is non-space.