Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in posts by eeree only
Search
Advanced Search
Forums
Product Launch
Updates
Today's Posts
Member List
Calendar
Home
eeree
User Profile
Collapse
Profile Sidebar
Collapse
eeree
Last Activity: Nov 23 '11, 08:15 PM
Joined: Nov 23 '11
Location:
Subscriptions
1
Subscribers
0
Activities
About
Media
Subscribed
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Source
All
eeree only
Visitor Messages Only
Advanced
Filtered by:
Clear All
new posts
eeree
replied to
count number of words in a string
in
Java
Nov 23 '11, 08:15 PM
Try splitting with Regular Expressions instead of using " " as delimiter:
Code:
String[] arr = input.split("\\s+"); int length = arr.length;
That code will split String on any space character (space \n \r or \t) (if there is more characters in a row it will split only once).
See more
|
Go to post
Leave a comment:
Post Comment
Cancel
No activity results to display
Show More
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Leave a comment: