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

ความคิดเห็น • 67

  • @theottomans7164
    @theottomans7164 ปีที่แล้ว +4

    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.

  • @madhukandukuri123
    @madhukandukuri123 3 หลายเดือนก่อน

    Using stringbuilder :
    String s[]=sc.nextLine().split(" ");
    for(int i=0;i

  • @gottepavani1838
    @gottepavani1838 2 ปีที่แล้ว

    Sir what if we want to get only "emocwel to java"

  • @Random_JapGuy
    @Random_JapGuy 2 ปีที่แล้ว

    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 ”.

  • @shoaibkolkata
    @shoaibkolkata 3 ปีที่แล้ว +12

    Thanks for the explanation. I was asked this question multiple times in interview. Hope won't miss it now.

    • @Raj-ql2vz
      @Raj-ql2vz ปีที่แล้ว +1

      easy hi toh hai bhai

  • @abhishekpaul2609
    @abhishekpaul2609 3 ปีที่แล้ว

    Sir how to get next-to- last word of a inputed string

  • @abhikatta2883
    @abhikatta2883 3 ปีที่แล้ว +1

    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

  • @vipintekade6400
    @vipintekade6400 ปีที่แล้ว +2

    Thanks pavan for sharing useful interview question .

  • @srisai8795
    @srisai8795 4 ปีที่แล้ว +1

    your explanation makes programing ease

  • @dewanganskitchen1117
    @dewanganskitchen1117 2 ปีที่แล้ว

    Hi sir I can you please tell me how to reverse a word like
    I like java
    a vaje kili

  • @SimpleProgrammer0
    @SimpleProgrammer0 2 ปีที่แล้ว +2

    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

    • @SimpleProgrammer0
      @SimpleProgrammer0 ปีที่แล้ว

      @Aditya Ashutosh yeah bro I get offers from 9 companies

  • @itachi-senpaii
    @itachi-senpaii 2 ปีที่แล้ว +1

    Thanks a lot ... it is very helpful ...

    • @sdetpavan
      @sdetpavan  2 ปีที่แล้ว

      Glad it was helpful!

  • @subhashishbehera7415
    @subhashishbehera7415 3 ปีที่แล้ว +1

    Great sir , easy too

  • @khagendramohanta2127
    @khagendramohanta2127 2 ปีที่แล้ว +1

    Input-"I am so happy here";
    Output - here happy so am i
    Plz solve anyone ?

  • @seemasainani4888
    @seemasainani4888 2 ปีที่แล้ว +3

    Thanks for explanation sir. i tried a lot but could not solve it but u made the concept clear

    • @sdetpavan
      @sdetpavan  ปีที่แล้ว

      You are most welcome

  • @onestepahead4507
    @onestepahead4507 4 ปีที่แล้ว

    Gazab trick

  • @keerthidammu7700
    @keerthidammu7700 4 ปีที่แล้ว

    Awesome sir...

  • @aestheticcalisthenics2836
    @aestheticcalisthenics2836 3 หลายเดือนก่อน +1

    great explanation

    • @sdetpavan
      @sdetpavan  3 หลายเดือนก่อน

      Thanks

  • @NEHAKUMARI-xu3cw
    @NEHAKUMARI-xu3cw 3 ปีที่แล้ว +2

    Nice explanation 🔥

  • @sundipchakraborty9038
    @sundipchakraborty9038 4 ปีที่แล้ว +1

    Easiest explanation I found on the internet.

  • @naveenreddy127
    @naveenreddy127 3 ปีที่แล้ว +10

    String name = "welcome to java";
    Arrays.stream(name.split(" "))
    .forEach(word -> {
    String reverse = "";
    reverse = reverse + new StringBuilder(word).reverse();
    System.out.print(reverse + " ");
    });

  • @mohammedajazquadri7869
    @mohammedajazquadri7869 4 ปีที่แล้ว

    Brilliant sir

  • @meghanaballa4966
    @meghanaballa4966 2 ปีที่แล้ว +1

    thank you!!

    • @sdetpavan
      @sdetpavan  ปีที่แล้ว

      You're welcome!

  • @sowjanyach8018
    @sowjanyach8018 2 ปีที่แล้ว +1

    Help full

  • @lakshmidevilakshmidevi3984
    @lakshmidevilakshmidevi3984 ปีที่แล้ว +1

    Best explanation

  • @LifeIsJustAPlay
    @LifeIsJustAPlay 2 ปีที่แล้ว

    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..

  • @Vinaykumar-rs5se
    @Vinaykumar-rs5se 3 ปีที่แล้ว +1

    Great explanation sir...

  • @simardeepkaur8275
    @simardeepkaur8275 2 ปีที่แล้ว

    Thanks

  • @gottepavani1838
    @gottepavani1838 2 ปีที่แล้ว +2

    Sir if v want input :hai sir and output:iah sir like this sir

  • @nainagupta4949
    @nainagupta4949 ปีที่แล้ว

    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

  • @uchary6374
    @uchary6374 2 ปีที่แล้ว

    Do the same for double dimensional arrays sir

  • @kvelez
    @kvelez 10 หลายเดือนก่อน +1

    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);
    }
    }

  • @JyotiVerma-zc1uc
    @JyotiVerma-zc1uc 4 ปีที่แล้ว +5

    reverse the each word of the string except 1st and last character of string.sir how to solve this question

    • @EdClarkHYCT
      @EdClarkHYCT 4 ปีที่แล้ว

      Jyoti Verma - try this: Reverse Odd Length Words Java Coding Challenge | How'd You Code That? | Episode 27. Please Like, Share, Subscribe!

    • @nayangourkar198
      @nayangourkar198 3 ปีที่แล้ว

      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);

    • @sanjaym2490
      @sanjaym2490 2 ปีที่แล้ว +1

      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();
      }
      }
      }

    • @arvindsharma801
      @arvindsharma801 ปีที่แล้ว +1

      @@nayangourkar198 This will not work because here we need to iterate the loop based on index advanced for loop wont work here

  • @Mnv_Sadiwala
    @Mnv_Sadiwala ปีที่แล้ว

    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.

  • @sweetthirty2
    @sweetthirty2 2 ปีที่แล้ว +1

    sir how to print "i love java"-----> "java love i"

    • @prasoonlall9432
      @prasoonlall9432 2 ปีที่แล้ว

      Traverse the words array backwards and print it.

    • @rajeshbhoin8678
      @rajeshbhoin8678 2 ปีที่แล้ว

      Split the string store in atray and then print array from length to 0

  • @ManishKumar-bh6yc
    @ManishKumar-bh6yc ปีที่แล้ว

    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);

  • @PavanKumar-gj8ef
    @PavanKumar-gj8ef 3 ปีที่แล้ว

    Diagram is wrong

  • @bihari1422
    @bihari1422 2 ปีที่แล้ว +3

    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);
    }
    }

  • @r0hith1999
    @r0hith1999 2 ปีที่แล้ว +1

    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

  • @shubhamsaurabh-ee7ev
    @shubhamsaurabh-ee7ev 11 หลายเดือนก่อน

    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(" ");

    }
    }
    }"

  • @SandeepSandeep-x1u
    @SandeepSandeep-x1u 23 วันที่ผ่านมา

    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........

  • @buzyfuzzymom
    @buzyfuzzymom 3 หลายเดือนก่อน

    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