 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a java program reverse tOGGLE each word in the string?
To perform a reverse toggle split the words of a string, reverse each word using the split() method, change the first letter of each word to lower case and remaining letters to upper case.
Example
import java.lang.StringBuffer; public class ToggleReverse {    public static void main(String args[]){       String sample = "Hello How are you";       String[] words = sample.split(" ");       String result = "";       for(String word:words){          StringBuffer s = new StringBuffer(word);          word = s.reverse().toString();          String firstSub = word.substring(0, 1);          String secondSub = word.substring(1);          result = result+firstSub.toLowerCase()+secondSub.toUpperCase()+" ";       }       System.out.println(result);    } }  Output
oLLEH wOH eRA uOY
Advertisements
 