A method that takes two String parameters, returns the number of times the second string appears in the first string.
public static int substringCount(String s1, String s2)
{
int count = 0;
int i = 0;
while ((i = s1.indexOf(s2, i)) != -1)
{
count++;
i += s2.length();
}
return count;
}
What is string?
A string is typically a sequence of characters in computer programming, either as a literal constant or as some sort of variable. The latter can either be fixed or its elements and length can be changed (after creation). A string is typically implemented as just an array data structure of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. A string is generally thought of as a type of data. A string can also represent other sequence(or list) data types and structures, such as more general arrays. A variable declared to be a string may cause memory storage to be statically allocated for just a predetermined maximum length or utilise dynamic allocation to allow this to hold a variable number of elements, depending on this same programming language and specific data type used.
To learn more about string
https://brainly.com/question/28290531
#SPJ13
difference between electronic and non electronic components
Answer:
The working principle of both of them are same, i.e., uses the electrical energy for doing work. The major difference between the electrical and electronic devices is that the electrical devices convert the electrical energy into the other form of energy like heat, light, sound, etc