Thursday, 2 April 2015

Java Tutorial... How to write code for determining Strings starts or ends with particular substring ?

public class Main
{
    public static void main(String[] args)
{
String[] a={"sell","well","help","hell"} ; // Array of strings
for(String x:a)
if(x.startsWith("he"))
System.out.printf(" Strings that starts with he :" + x +"\n");
for(String x:a)
if(x.endsWith("ll"))
System.out.printf(" Strings that ends with ll :" + x + "\n");

   
}
}

No comments:

Post a Comment

Grammar Mistakes in Technical Paper Writing

Let me share some experience in this post with you. I'm currently in the second year of my Ph.D. program. We are in the middle of paper...