Thread View: aus.computers.java
3 messages
3 total messages
Started by ronnie gillis
Fri, 12 Nov 1999 00:00
Searching a string in Java for a Substring, anyone know how?
Author: ronnie gillis
Date: Fri, 12 Nov 1999 00:00
Date: Fri, 12 Nov 1999 00:00
7 lines
1094 bytes
1094 bytes
I have a computer assignment that is due next week and we have to be able to search a string entered by the user, for a substring that is entered by another user. We have only just learned the basics of Java and some methods and designing classes. We are just in the midst of learninig if statements and it somehow must relate to this but I can't wrap my head around it. We haven't used many methods that would search a string. PLEASE HELP!!!!!!!!!!!!!!!!!
Re: Searching a string in Java for a Substring, anyone know how?
Author: Goo
Date: Sat, 13 Nov 1999 00:00
Date: Sat, 13 Nov 1999 00:00
20 lines
1459 bytes
1459 bytes
In article <382c242b.4852097@news.mtt.net>, ronnie gillis <warren.buffet@usa.net> wrote: >I have a computer assignment that is due next week and we have to be >able to search a string entered by the user, for a substring that is >entered by another user. We have only just learned the basics of >Java and some methods and designing classes. We are just in the midst >of learninig if statements and it somehow must relate to this but I >can't wrap my head around it. We haven't used many methods that would >search a string. PLEASE HELP!!!!!!!!!!!!!!!!! Umm, how about looking at the API documentation, specifically for the methods contained withing the String class? There is actually a method called 'substring' which does exactly what you want. You can download a copy of the API docs from http://java.sun.com. HTH, goo
Re: Searching a string in Java for a Substring, anyone know how?
Author: Cannon
Date: Wed, 01 Dec 1999 00:00
Date: Wed, 01 Dec 1999 00:00
19 lines
1522 bytes
1522 bytes
How about:
String str = s.toLowerCase();
if (str.indexOf("find me")>-1){
System.out.println("Found you!");
}
--
#WB###
Don't e-mail if your a student. I hate students, spam and attachments.
ronnie gillis <warren.buffet@usa.net> wrote in message
news:382c242b.4852097@news.mtt.net...
> I have a computer assignment that is due next week and we have to be
> able to search a string entered by the user, for a substring that is
> entered by another user. We have only just learned the basics of
> Java and some methods and designing classes. We are just in the midst
> of learninig if statements and it somehow must relate to this but I
> can't wrap my head around it. We haven't used many methods that would
> search a string. PLEASE HELP!!!!!!!!!!!!!!!!!
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads