Question Index

Given the input string, then write a program to prefix only the first occurrence of every character in the given input string. i.e. if the same character is repeated then only prefix for the first occurrence.

Input (String, Char) Output (String)
Coconut, T TCTocoTnTuTt
Dhoni, E EDEhEoEnEi
Potatoo, H HPHoHtHatoo
Tatoo, P PTPatPoo
Welcome, R RWReRlRcRoRme

class PrefixFirstOccurrenceOfEveryCharacter
    public static void main(String s[])
        System.out.println("After prefixing : " + prefixEveryCharacter("Coconut", 'T'));


    public static String prefixEveryCharacter(String word, char prefix) {




Topic: toLowerCase() And toUpperCase() Methods In Java

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App