Java Program For String Methods
Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
package testcoreproject;
public class TestStringMethod
{
public static void main(String[] args)
{
// String S="Data Flair";
// System.out.println(S.toUpperCase().length());
System.out.println("data flair".toUpperCase());
// String S="ABCDE";
// byte b[];
// b=S.getBytes();
// for (int i = 0; i < b.length; i++)
// {
// System.out.print(b[i]+ " ");
// }
// String email="[email protected]";
// int m,n;
// m=email.indexOf('@');
// if(m==-1)
// System.out.println("Invalid Email id ....");
// else
// {
// n=email.indexOf('.', m+1);
// if(n==-1)
// System.out.println("Invalid Email id ....");
// else
// System.out.println("Valid Email ... Wel come");
// }
//String S=new String("Wel come in dataflair free java course");
//char ch[];
// ch=S.toCharArray();
// for(int i=0;i<ch.length;i++)
// System.out.println(ch[i]);
// System.out.println(S.indexOf("java"));
// System.out.println(S.toUpperCase());
// int n,i,count=0;
// n=S.indexOf('e',8);
// System.out.println(n);
//
//
// length method
//n=S.length();
//System.out.println("Length of String: "+n);
//char At
// System.out.println(S.charAt(5));
//Space Count
// for(i=0;i<S.length();i++)
// {
// if(S.charAt(i)==' ')
// count++;
// }
// System.out.println("Total Space : "+count);
// char ch;
// for(i=0;i<S.length();i++)
// {
// ch=S.charAt(i);
// if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
// count++;
// }
// System.out.println("Total Vowel : "+count);
// for(i=S.length()-1;i>=0;i--)
// System.out.print(S.charAt(i));
}
}
Your opinion matters
Please write your valuable feedback about DataFlair on Google

