Convert String to Capitalize String in java

Поделиться
HTML-код
  • Опубликовано: 15 янв 2025

Комментарии • 25

  • @tapaskhandai
    @tapaskhandai 2 года назад +2

    Hi Naveen Thanks for great work you are doing that helps Automation tester like me a lot. I tried this in another way like below:
    static void capitalizeString(String str) {
    String result = "";
    String[] ar = str.split("\\s");
    for (String s : ar) {
    char c = Character.toUpperCase(s.charAt(0));
    result = result + s.replace(s.charAt(0), c)+" ";
    }
    System.out.println(result);
    }

    • @rgawali9
      @rgawali9 Год назад

      In this if I want to uppercase only 3character of 2nd word how can we do it?

  • @testinginsights-muktasharma
    @testinginsights-muktasharma 2 года назад +1

    Great demonstration to make us understand the concept. Thank you!

  • @kapilsachan
    @kapilsachan 2 года назад +1

    This is: *The* Naveen Automation Lab guys....

  • @deepa8177
    @deepa8177 2 года назад +2

    Thanks for covering test cases also, it actually helps to think in those directions also as a beginner in coding.

  • @SarangHoley
    @SarangHoley 2 года назад

    Thanks Naveen for Covering the Multiple Checks concept in the video 👍😊

  • @umeshjoshi8047
    @umeshjoshi8047 2 года назад +2

    Thanks @Naveen AutomationLabs for video .
    What if there is more than one space between two words of String [E.g:- String s="naveen automations labs" ]
    if we apply this check in for loop we can cover above case also
    if(word.length()>0){
    //logic of converting first letter of word to captial and appending to result string;
    }

    • @naveenautomationlabs
      @naveenautomationlabs  2 года назад +5

      it can be easily handled by using \\s+. String words[] = str.split("\\s+");

  • @reks5936
    @reks5936 2 года назад +1

    Hi Naveen, Thanks for your continuous videos which is very much helpful to clear the interviews.. kindly explain in a video about when to use static and non static variables in real-time testing

  • @sphanindra5981
    @sphanindra5981 2 года назад +1

    Please tell how to solve this type of string string s= 2**7***9; output like 2357859

  • @sureshgarine
    @sureshgarine 2 года назад +1

    Hi Naveen, thank you for starting on coding questions, Please continue the good work.
    I solved it without Split and upper case function, making it very performant with String builder and ASCII conversion.
    Added comments for better reach
    My solution
    private static String camelCaseSentence(String str) {
    if(str.length()== 0 || str == null)
    return str;
    StringBuilder sb = new StringBuilder();
    sb.append((char)(str.charAt(0) -'a'+'A'));//converting the character with ascii value, first trying to find difference and add it to ascii value of 'A'
    //and typecast to integer value
    for (int i = 1; i < str.length(); i++) {
    if(!(str.charAt(i)==' ')){
    sb.append(str.charAt(i));
    }else{ //skipping space and convert next char to upper case and increment so that it won't print again
    sb.append((char)(str.charAt(i+1) -'a'+'A')); // same as above comments.
    i++;
    }
    }
    return sb.toString();
    }

  • @Ram_5
    @Ram_5 2 года назад

    Hi Naveen,
    Can you please tell me solutions for the question in the below.
    Split a String but don't split when character repeats.. input s="aHHHbYY";
    Out put would be like output:[a, HHH, b, YY]
    Thanks in advance.
    Ragards,
    Kanvitha

    • @gagans.rgowda5820
      @gagans.rgowda5820 Год назад

      public static String[] split_string(String str) {

      String res ="";
      for(int i=0; i

  • @sunitasenapati6569
    @sunitasenapati6569 2 года назад

    Hii is there any online course is available in your lab..???

  • @hakimakbary65
    @hakimakbary65 2 года назад

    Hi Naveen,
    Any plans to do series on XCUITest and locators in this framework? Please 😄

  • @immortalhuman7085
    @immortalhuman7085 2 года назад

    What if interviewer asks not to use any String method like toUpperCase()

    • @Savin.Shetty
      @Savin.Shetty 2 года назад

      Capture string in in char array, iterate through the array. Get ASCI value of each char subtract that with 32 your will get you upper case ASCI value, that's it. Same works the other way round, as A - 65 and a - 97, rest follows.

    • @sureshgarine
      @sureshgarine 2 года назад

      hi @sameer, please see my solution in the comments above. I did more efficiently

    • @sureshgarine
      @sureshgarine 2 года назад

      @@Savin.Shetty I did the same :)

    • @immortalhuman7085
      @immortalhuman7085 2 года назад

      @@sureshgarine your comment not visible bro.

    • @sureshgarine
      @sureshgarine 2 года назад

      @@immortalhuman7085 can you please see, i can see it. check with in 1 hr

  • @foddiebyage9696
    @foddiebyage9696 2 года назад

    Sir pls serialization in java, logging, monitoring or apps