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.
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
You have to read the API documentation; (this link is for version 1.6; google for version 1.7). In the String API it suggests to use the indexOf( ... ) method.