Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:59:47+00:00 2026-06-10T09:59:47+00:00

Hey guy’s I tried to find a way to hide a string, but the

  • 0

Hey guy’s I tried to find a way to hide a string, but the code that I found just work with my application… Is there a way to hide the characters in a string with either * or - and if there is can someone please explain

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:59:48+00:00Added an answer on June 10, 2026 at 9:59 am

    Is this for making a password? Consider the following:

    class Password {
        final String password; // the string to mask
        Password(String password) { this.password = password; } // needs null protection
        // allow this to be equal to any string
        // reconsider this approach if adding it to a map or something?
        public boolean equals(Object o) {
            return password.equals(o);
        }
        // we don't need anything special that the string doesnt
        public int hashCode() { return password.hashCode(); }
        // send stars if anyone asks to see the string - consider sending just
        // "******" instead of the length, that way you don't reveal the password's length
        // which might be protected information
        public String toString() {
            StringBuilder sb = new StringBuilder();
            for(int i = 0; < password.length(); i++) 
                sb.append("*");
            return sb.toString();
        }
    }
    

    Or for the hangman approach

    class Hangman {
        final String word;
        final BitSet revealed;
        public Hangman(String word) {
            this.word = word;
            this.revealed = new BitSet(word.length());
            reveal(' ');
            reveal('-');
        }
        public void reveal(char c) {
            for(int i = 0; i < word.length; i++) {
                if(word.charAt(i) == c) revealed.set(i);
            }
        }
        public boolean solve(String guess) {
            return word.equals(guess);
        }
        public String toString() {
             StringBuilder sb = new StringBuilder(word.length());
             for(int i = 0; i < word.length; i++) {
                 char c = revealed.isSet(i) ? word.charAt(i) : "*";
             }
             return sb.toString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys. I've just published my first Android application to show this guy who
Hey guy's I can't figure out why my code doesn't work when I have
Hey i have been looking around and i cant find a way to get
Hey guys I wanted to create a JScrollPane but it won't work... and I
Hey guy's First of all thanks for reading this. I'm having trouble to find
Hey all, just wondering what the best way to add this capability was. I
Hey guy i have following problem: I have this line of code which includes
Hey, I've developed an application with french and english translation. A guy sent me
Hey guy's just a quick question. Im making a sortable, drag and drop system
Hey everyone, a new guy here in C#.Net. I'm trying to make an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.