Need help with what I think should be a for loop
I am new to Java and I am trying to learn it by myself along with taking a class for it.
I have a question about strings
I am trying to write a small program that takes two strings from using input (lets call them String a and String b) and compare them.
An example of how I am trying to compare would be:
String a= CATSATONTHEMAT String b= AT and I need to output to be how many times "AT" appears in String a
Is that the string compare function? I have tried setting up a for loop with a counter, but was unsuccessful. Am I on the right track with this?
I do not want someone to just give me code that works, just some suggestions that might help me get to the correct line of thinking.
Any help would be awesome
Re: Need help with what I think should be a for loop
What String class methods have you tried? Look at the String class's indexOf method.
Also posted at: http://www.java-forums.org/new-java/62807-strings.html