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

  • Home
  • SEARCH
  • 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 6856893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:56:44+00:00 2026-05-27T01:56:44+00:00

So I want to search through a string to see if it contains the

  • 0

So I want to search through a string to see if it contains the substring that I’m looking for. This is the algorithm I wrote up:

    //Declares the String to be searched
    String temp = "Hello World?";

    //A String array is created to store the individual 
    //substrings in temp
    String[] array = temp.split(" ");

    //Iterates through String array and determines if the
    //substring is present
    for(String a : array)
    {
        if(a.equalsIgnoreCase("hello"))
        {
            System.out.println("Found");
            break;
        }
        System.out.println("Not Found");
    }

This algorithm works for “hello” but I don’t know how to get it to work for “world” since it has a question mark attached to it.

Thanks for any help!

  • 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-27T01:56:44+00:00Added an answer on May 27, 2026 at 1:56 am

    Take a look:
    http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#contains(java.lang.CharSequence)

    String.contains();
    

    To get a containsIgnoreCase(), you’ll have to make your searchword and your String toLowerCase().

    Take a look at this answer:
    How to check if a String contains another String in a case insensitive manner in Java?

    return s1.toLowerCase().contains(s2.toLowerCase());
    

    This will also be true for:
    war of the worlds, because it will find world. If you don’t want this behavior, youll have to change your method like @Bart Kiers said.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of data that I want to search through. This new
I want to search two item (name=string and location=json). this search is (one input
I've got this Excel Workbook which I want to search for a specific string
I want to search through a html file and then get the url to
Similar Stack Overflow Question I want users to be able to search through my
We want to search a file to find all instances of bar that are
I have a string in a bash script that contains a line of a
So I have this table, and I want to go through in Python, and
I have a string that holds user input. This string can contain various types
For this question, I'm looking to see if anyone has a better idea of

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.