//Code - Common String Method // from newBoston
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public class ItCommonStringMethod
{
public static void main(String[] args)
{
String[] words = { "funk", "chunk", "furry","baconator"};
// Strat with
for (String w : words)
{
if (w.startsWith("fu"))
System.out.println(w + "starts with fu");
}
// ends with
for (String w : words)
{
if (w.endsWith("unk"))
System.out.println(w + " ends with unk");
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You will Get output like below :-
funkstarts with fu
furrystarts with fu
funk ends with unk
chunk ends with unk
No comments:
Post a Comment