Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
Split Method in String Class
Srinivas Katta
Ranch Hand
Posts: 76
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
Can anybody explain the below Code
String s="Sun Exam"; s=s.split("\\s")[s.split("\\s").length-1]; System.out.println(s)
Thanks
Srinivas
Srinivas Katta
Ranch Hand
Posts: 76
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It is in
String
class not Spring class
Martin Vanyavchich
Ranch Hand
Posts: 241
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Here is a bit extended and explained version.
String s="Sun Exam"; // splits the string around white spaces ("\\s" is regex for white space) into a String array String[] splittedString = s.split("\\s"); s = splittedString[splittedString.length-1]; // from splitted array, get the last item System.out.println(s); // print last item
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Srinivas Katta
Ranch Hand
Posts: 76
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks a lot for the explanation
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Regular Expressions in String.split()
splitting string into 2 variable
String split
remove char
StringTokenizer tab delimiter
More...