public class Text
{
public static void main (String[] args)
{
String text = "This will be the text that I'm working with";
//int.length (String text)
//char charAt (int index)
int letterCounter = 0;
for (int i = 0; i < text.length (); i++)
//"i" means index
{
if (text.charAt (i) == 'i' || text.charAt(i) == 'I')
{
letterCounter++;
}
}
System.out.println (letterCounter);
}
}
{
public static void main (String[] args)
{
String text = "This will be the text that I'm working with";
//int.length (String text)
//char charAt (int index)
int letterCounter = 0;
for (int i = 0; i < text.length (); i++)
//"i" means index
{
if (text.charAt (i) == 'i' || text.charAt(i) == 'I')
{
letterCounter++;
}
}
System.out.println (letterCounter);
}
}
(0) Comments
Post a Comment