- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The most elegant ways to iterate the words of a java string.
Just split the string based on space and then iterate it. See the example below −
Example
public class Tester { public static void main(String[] args) { String test = "I love learning Java"; String[] subStrings = test.split(" "); for(String subString: subStrings) { System.out.println(subString); } } }
Output
I love learning Java
Advertisements