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 7683969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:55:05+00:00 2026-05-31T18:55:05+00:00

I have one method with one letter(string\char?) as argument and one word active at

  • 0

I have one method with one letter(string\char?) as argument and one word active at a time. I would like to see if this one letter, is in the word which is active at the time.

That could probably have been explained better. Maybe code will do the trick:

public void checkLetter(String letter){
        for(int i = 0; i<activeWord.length(); i++){
            if(letter.equals(activeWord.[i])){
                // Run a method which gives the user a correct letter pushed.
                }
                else {
                    String failed = "Could not find the letter in the active word.";
                    // Run a method which gives the user one wrong letter pushed.
                }
            }           
    }

So, this is going to be a hangman game for android i’m making for fun. Right now i have images as letters. When the letter(image) is pressed, this method runs, and the letter pushed will be the argument.

Does anyone have any good ideas how i can find out if the letter is in the word, and which posistion it is in?

I would love some help 🙂

EDIT: Btw, the current code returns int every time ofc, cause the [i] is an int. This is where im strugling to get the code to return a string. Do i have to split the word up into letter before i can equal them to another string?
Thanks.

  • 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-05-31T18:55:06+00:00Added an answer on May 31, 2026 at 6:55 pm

    use String’s methods

    int i = 0;
    while(word.indexOf(i, letter) != -1) {
       i = word.indexOf(i, letter) + 1;
       //Do whatever
    }
    
    if(i == 0) {
       //Handle missed letter 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one method in my managed bean which returns javascript as a string.
I have one combobox on the window form and I have one method which
I have class which have one public method Start , one private method and
I'm creating a class that will have one public method, which returns a value
I have one method that opens a file and passes off to another function
I have a project with a lot of panels. I have one method that
I have one doubt concerning c# method overloading and call resolution. Let's suppose I
I have a very thin interface that's going to define one method. Should I
I have a button on the window form and and one method I am
I have a re-occurring design problem with certain classes which require one-off initialization with

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.