Frequently Asked Java Program 28: How To Reverse Each Word in a String
ฝัง
- เผยแพร่เมื่อ 20 ต.ค. 2019
- Topic : How To Reverse Each Word in a String
#########################
Udemy Courses:
#########################
Manual Testing+Agile with Jira Tool
************************************
► shorturl.at/xNXZ4
Selenium with Java+Cucumber
********************************
► shorturl.at/aIKMW
Selenium with Python & PyTest
********************************
► shorturl.at/ELW09
Selenium with python using Robot framework
****************************************
► shorturl.at/bcDPZ
API Testing(Postman, RestAssured & SoapUI)
*****************************************
► shorturl.at/uAWY7
Web & API Automation using Cypress with Javascript
********************************************
► rb.gy/4uum2n
Playwright with Javascript
**************************
► shorturl.at/gALZ1
Jmeter-Performance Testing
************************
► rb.gy/ocj7r2
SDET Essencials(Full Stack QA)
*************************
► rb.gy/hlnf2v
Appium-Mobile Automation Testing
************************************
► rb.gy/wmzv64
Java Collections
*****************
► bit.ly/3S66ezE
Python Programming
*********************
► urlis.net/gdsfpb0s
Cucumber BDD Framework
***************************
► bit.ly/3F7d69r
Protractor with Javascript
***************************
► urlis.net/4uddm1qb
####################################
TH-cam Playlists:
####################################
Manual Testing & Agile
***********************
► bit.ly/3ujvaYa
► bit.ly/3OYzxQj
SQL
*************************
► bit.ly/3R6XjeG
► bit.ly/3nE0a1s
► bit.ly/3IeKuuJ
linux & Shell Scripting
**********************
► bit.ly/3up1Z6a
► bit.ly/3nzvGxx
Java
**********************
► bit.ly/3R9QfOs
► bit.ly/3AoRMKM
► bit.ly/3IbTTDn
► bit.ly/3ybXInv
► bit.ly/3yCoHdw
Selenium With Java+Cucumber
********************************
► bit.ly/3P2FMm4
► bit.ly/3yhiIt4
► bit.ly/3uokzet
► bit.ly/3a7XIND
► bit.ly/3umN2S9
► bit.ly/3aar7GW
► bit.ly/3y9kD2S
► bit.ly/3uhLskn
Python
********************************
► bit.ly/3agNgU0
► bit.ly/3NJNnoy
► bit.ly/2CTQ4mR
► bit.ly/3OIYWh1
Selenium With Python,Pytest&Behave
***************************************
► bit.ly/3OHHoC9
► bit.ly/3IeNLdv
► bit.ly/2J4tPeT
► bit.ly/3ydSkAq
Selenium With Python Using Robert Framework
(Web&API Testing)
*************************************************
► bit.ly/3nUvlpr
► bit.ly/3nUvE3z
API Testing (Postman,SoapUi,&Rest Assured)
**********************************************
► bit.ly/3OXacWY
► bit.ly/3yh0UhE
► bit.ly/3nC9DWQ
► bit.ly/3yGfhNS
► bit.ly/3OJa11H
► bit.ly/3P2slCC
Mobile App Testing Appium
****************************
► bit.ly/3Al49HG
Performance Testing Jmeter
*******************************
► bit.ly/3nz4fE7
Maven,Jenkins,Git,Github,CI/CD
*******************************
► bit.ly/3P16HPj
► bit.ly/3yhlUVA
► bit.ly/3afYfwT
► bit.ly/3yGzweG
► bit.ly/3yF73Ws
► bit.ly/3NCOmH7
SQL,DB Testing&ETL,Bigdata
*******************************
► bit.ly/3NKOcNY
► bit.ly/3OVpDyI
► bit.ly/3NEvUy0
► bit.ly/3IryxlT
► bit.ly/3RkWBLh
JavaScript Based Automation Tools
********************************
► bit.ly/3nUx51X
► bit.ly/3AqI6Q0
► bit.ly/3yeurbT
► bit.ly/3ujzpTK
Selector Hub Tools
********************
►rb.gy/h3h424
GraphQL
******************
► rb.gy/sj3gys
Cypress API Testing
********************
► shorturl.at/fjKPX
Cypress Web Testing
**********************
► shorturl.at/agjlK
Playwright with Javascipt
**************************
► shorturl.at/adSTY
#PythonStringReverse
#WordReversalInPython
#StringManipulation
#PythonCodingChallenge
#StringWordReverse
#PythonStringOperations
#ReverseWordsInString
#PythonCodingTips
#StringProcessing
#PythonStringTricks
#WordOrderReversal
#PythonAlgorithm
#CodingPractice
#StringSplitAndReverse
#PythonProgramming
#StringWordOrderChange
#CodeSnippets
#PythonBeginners
#StringManipulationInPython
#AlgorithmInPython
#CodeLogic
#PythonTipsAndTricks
#StringReversalTechnique
#PythonLearning
#CodingCommunity
#StringReverseChallenge
#PythonStrings
#ReverseEachWord
#ProgrammingInPython
#StringHandling
#PythonCodingCommunity
#WordReversalChallenge
#PythonPuzzles
#StringReverseMethod
#PythonDev
#CodingHelp
#StringReverseFunction
#PythonTricks
#AlgorithmicThinking
#StringReversalAlgorithm
#PythonProblemSolving
#CodeDebugging
#StringReverseExplained
#PythonSolutions
#CodeEfficiency
#StringWordManipulation
#PythonSnippets
#ProgrammingLogic
#StringReverseTutorial
#PythonCodingJourney
Your explanation, concept and playlist on every trending technology has made a huge impact on the learning talent pool, helping them to upskill themselves and understand the application of technology in the real time projects.
Using stringbuilder :
String s[]=sc.nextLine().split(" ");
for(int i=0;i
Sir what if we want to get only "emocwel to java"
java program that will transfer the middle character of words in an input sentence and
place it at the back of the word and add “AVA ”.
Thanks for the explanation. I was asked this question multiple times in interview. Hope won't miss it now.
easy hi toh hai bhai
Sir how to get next-to- last word of a inputed string
hi the first one didn't worked getting eror:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
i cannot be resolved to a variable
at package1.Reversestring.main(Reversestring.java:20)
public class Reversestring {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str ="welcome to india";
String[] words = str.split("//s");
String reversestring = " ";
for(String w:words)//welcome
{
String reverseword="";
for(int i=w.length()-1;i>=0;i--);
{
reverseword=reverseword+w.charAt(i);
}
reversestring= reversestring+reverseword+" ";
}
System.out.println( reversestring);
}
}
@SDET - QA Automation Techie
Thanks pavan for sharing useful interview question .
Welcome
your explanation makes programing ease
Hi sir I can you please tell me how to reverse a word like
I like java
a vaje kili
the great explanation
I am coming from coding ninja to youtube to learn and understand this problem thnxxxx really from the bottom of my hearts
@Aditya Ashutosh yeah bro I get offers from 9 companies
Thanks a lot ... it is very helpful ...
Glad it was helpful!
Great sir , easy too
Thanks
Input-"I am so happy here";
Output - here happy so am i
Plz solve anyone ?
Thanks for explanation sir. i tried a lot but could not solve it but u made the concept clear
You are most welcome
Gazab trick
Awesome sir...
Thanks
great explanation
Thanks
Nice explanation 🔥
Thanks
Easiest explanation I found on the internet.
Thanks
String name = "welcome to java";
Arrays.stream(name.split(" "))
.forEach(word -> {
String reverse = "";
reverse = reverse + new StringBuilder(word).reverse();
System.out.print(reverse + " ");
});
Wrong program ...
Brilliant sir
Thanks
thank you!!
You're welcome!
Help full
thanks
Best explanation
Thanks
u need to trim the final String... there is an extra space at the end of it... It is not exact String which was expected... ur solution is incomplete... Fix it..
Great explanation sir...
Thanks
Thanks
Welcome
Sir if v want input :hai sir and output:iah sir like this sir
😂😂😂😂
how to reverse two sentences like
String s= "My name is Aish. I live in Banglore.";
o/p: Aish is name my. Banglore in live I.
Please reply
Do the same for double dimensional arrays sir
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter phrase: ");
String phrase = scanner.nextLine();
scanner.close();
StringBuffer bf = new StringBuffer();
bf.append(phrase).reverse();
System.out.println(bf);
}
}
reverse the each word of the string except 1st and last character of string.sir how to solve this question
Jyoti Verma - try this: Reverse Odd Length Words Java Coding Challenge | How'd You Code That? | Episode 27. Please Like, Share, Subscribe!
String str="Welcome to Java";
String strarr[]=str.split("\\s+");
String ans="";
for(String s:strarr) {
String temp=s.substring(1,s.length()-1);
StringBuilder sb=new StringBuilder(temp);
sb.reverse();
temp=sb.toString();
temp=s.charAt(0)+temp+s.charAt(s.length()-1);
ans+=" "+temp;
}
System.out.println(ans);
String str = "Java is here";
String[] st = str.split(" ");
String result ="";
for(int i=0;i0;j--) {
System.out.print(ch[j]);
}
System.out.println();
}
}
}
@@nayangourkar198 This will not work because here we need to iterate the loop based on index advanced for loop wont work here
How to skip last two words in sentence?
My input string is: Hi there. My name is Kalp. This is my lucky day. I like coding so much. This is it.
Expected output is: Hi there. name My is Kalp. my is This lucky day. coding like I so much. This is it.
sir how to print "i love java"-----> "java love i"
Traverse the words array backwards and print it.
Split the string store in atray and then print array from length to 0
Sir,
String s = "Hello World";
String str []= s.split("");
for(int i = str.length-1;i>=0;i--) {
System.out.print(str[i]);
}
o/p - dlroW olleH
is that correct?
Another way also i thought sir-
String s1 = "Hello World";
String s2 = "";
for(int i= s1.length()-1;i>=0;i--) {
s2=s2+s1.charAt(i);
}
System.out.println(s2);
Diagram is wrong
package SDET_QA_Automation;
public class ReverseEachWordInString {
public static void main(String[] args) {
// TODO Auto-generated method stub
String rev = "This has to be reverse";
String[] s = rev.split(" ");
String add = "";
for (int i = 0; i < s.length; i++) {
for (int j = s[i].length() - 1; j >= 0; j--) {
add += s[i].charAt(j);
}
add += " ";
}
System.out.println(add);
}
}
hello sir,
i did it like this
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String name="welcome to java";
String []st=new String[3];
st=name.split(" ");
String rev="";
for(int i=0;i
try this"//to reverse each word in given sentence
public class Program33 {
public static void main(String[] args) {
String s = "my name is lakhan";
String[] arr = s.split(" ");
for (int i = 0; i < arr.length; i++) {
for (int j = arr[i].length()- 1; j >= 0; j--) {
System.out.print(arr[i].charAt(j));
}
System.out.print(" ");
}
}
}"
String str="java is awesome";//avaj si emosewa
String []s=str.split(" ");
String temp="";
for (int i =0; i=0 ;j--) {
rev+=temp.charAt(j);
}
System.out.print(rev+" ");
like this very easy........
import java.util.ArrayList;
public class A32_ReverseEachWordOfString {
public static void main(String[] args) {
String s = "My name is Vidisha";
String [] sSplit = s.split(" ");
ArrayList revAl = new ArrayList();
for(String s1:sSplit) {
String rev = "";
for(int i=0;i