Java Program To Replace Character With It's Occurrence | Java | Ashok IT

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

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

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

    🔥 Welcome to Ashok IT..!!
    👉 Register Here For Online Training : bit.ly/4dBYJbX
    👉 Follow us in Instagram : bit.ly/3jzEKl8
    👉 Follow Us in WhatsApp : bit.ly/49wCWje
    👉 Visit Our Website : ashokit.in/

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

    for(int i = 0 ; i

  • @my_love_sanatan
    @my_love_sanatan 3 года назад +1

    9:05 why this will not work, not clear, does it mean it will store only single char of integer like not greater than 0-9 ?

  • @47lokeshkumar74
    @47lokeshkumar74 2 года назад +1

    Nice. Kindly give data structure video also

  • @YashSingh-xs5yj
    @YashSingh-xs5yj 2 месяца назад +1

    Sir, it was a great tutorial can you please help, one interview coding question which was based on String I was not able to solve that properly
    Input: abbcccdddd
    Output: ab2c3d4
    If the repetition of a char in a string is more than one, then it should be replaced by a number denoting the occurrence of that char in String

    • @ashokit
      @ashokit  2 месяца назад +1

      🔥 Please follow us in WhatsApp channel : bit.ly/49wCWje

  • @sainath2983
    @sainath2983 7 месяцев назад

    string str = "opentext";
    char ch = 't';
    int count = 48;
    char[] chars = str.ToCharArray();
    for (int i = 0; i < chars.Length; i++)
    {
    if (ch == chars[i])
    {
    count++;
    chars[i] = (char)count;
    }
    }
    Console.WriteLine(chars);

    • @ashokit
      @ashokit  2 месяца назад

      🔥 Please follow us in WhatsApp channel : bit.ly/49wCWje

  • @ajayghode3602
    @ajayghode3602 7 дней назад

    Thank you sir..
    I'm facing issue with
    if (input.indexOf(charToReplace == -1)) is not working...
    Error: The method indexOf(int) in the type String is not applicable for the arguments (boolean)
    Any one can help me with this plz..
    Thanks

    • @ashokit
      @ashokit  6 дней назад

      Please contact our admin team : 9985396677

  • @beastcombatanalysing635
    @beastcombatanalysing635 8 месяцев назад

    What would happen if we just did it as arr[i] = String.valueOf(cnt); ?

    • @ashokit
      @ashokit  3 месяца назад

      please contact our admin team : +91 9985396677

  • @YashSingh-xs5yj
    @YashSingh-xs5yj 2 месяца назад +1

    package StringQuestions;
    public class ReplaceCharWithCountOfRepetition {
    public static void main(String[] args) {
    String input = "opentext";
    char chCheck = 't';
    input = input.toLowerCase();
    if (input.indexOf(chCheck) == -1) {
    System.out.println("The Given Character is not present!");
    return; // Exit early if the character is not found
    }
    StringBuilder sb = new StringBuilder(input);
    int count = 1;
    for (int i = 0; i < sb.length(); i++) {
    if (sb.charAt(i) == chCheck) {
    sb.setCharAt(i, (char) ('0' + count));
    count++;
    }
    }
    System.out.println(sb.toString());
    }
    }

    • @ashokit
      @ashokit  2 месяца назад

      Please contact our admin team : 9985396677

  • @frustrated_majdoor
    @frustrated_majdoor 3 года назад +1

    Why are we using charAt(0)..plz explain

  • @umadevialamkonda8860
    @umadevialamkonda8860 2 месяца назад

    public static String Replace_occurances(String s,char rc) {

    StringBuilder ans= new StringBuilder();
    int count=1;
    if(s.indexOf(rc)==-1){
    System.out.println("The given character "+rc+" is not present in the String");
    }else{
    for(int i=0;i

    • @ashokit
      @ashokit  Месяц назад

      🔥 Please follow us in WhatsApp channel : bit.ly/49wCWje

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

    How to change only the second occurrence with different character?

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

      Please Contact Our Admin Team:wa.me/+919985396677
      👉 Subscribe To Our RUclips Channel: bit.ly/41IHJdj