- Trending Categories
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
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
- Related Articles
- Write a java program to tOGGLE each word in string?
- Write a java program to reverse each word in string?
- Write a Java program to capitalize each word in the string?
- Java program to reverse each word in a sentence
- Program to reverse the position of each word of a given string in Python
- Write program to reverse a String without using reverse() method in Java?
- Python program to reverse each word in a sentence?
- Java Program to Capitalize the first character of each word in a String
- Write a Golang program to reverse a string
- Java Program to Reverse a String
- Reverse each word in a linked list Node
- Find frequency of each word in a string in Java
- Extracting each word from a string using Regex in Java
- Write a program to reverse an array or string in C++
- Java program to reverse a string using recursion

Advertisements