Member-only story

Learn How to Write a Java Function to Uncensor Strings by Replacing Asterisks with Vowels

Censored Strings in Java: A Guide to Reconstructing Original Strings from Censored Text

Max N
2 min readJun 8, 2023
Photo by Romain Vignes on Unsplash

Introduction

In this tutorial, we’ll explore a Java programming problem that involves reconstructing original strings from censored text. We’ll create a function that takes a censored string with asterisks (*) replacing the vowels and a string of the censored vowels.

The function will return the original uncensored string by replacing the asterisks with the corresponding vowels. By the end of this post, you’ll have a better understanding of how to work with strings, loops, and character manipulation in Java.

Step 1: Defining the Function

First, let’s define a function called uncensor that takes two strings as arguments: the censored string and the string of censored vowels:

public static String uncensor(String censored, String vowels) {
// Reconstruct the original uncensored string
}

Step 2: Replacing the Asterisks with Vowels

We’ll use a loop to iterate through the censored string and a separate index to keep track…

--

--

Max N
Max N

Written by Max N

A writer that writes about JavaScript and Python to beginners. If you find my articles helpful, feel free to follow.

No responses yet