1) Remove Vowels from String:
package StringInJava;
public class RemoveVowelsFromString {
public static void main(String[] args) {
// TODO Auto-generated method stub
String S = "Hello, World!";
String R = [Link]("(?i)[aeiou]", ""); // (?i) makes
it case-insensitive
[Link]("Original String: " + S);
[Link]("String after removing vowels: " + R);
// The regular expression "(?i)[aeiou]":
// (?i) makes the regex case-insensitive.
// [aeiou] matches any vowel (both uppercase and lowercase).
// The replaceAll() method replaces all occurrences of vowels with an empty
string "", effectively removing them from the string.
2) Reverse String:
package StringInJava;
public class ReverseStringProgram {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s="madam";
String t=" ";
for(int i=[Link]()-1;i>=0;i--) {
t=t + [Link](i);
[Link](t);
if([Link](t))
[Link]("Given string is pollindrome");
else {
[Link]("String is not pollindrome");
}
}
3)String Methods:
package StringInJava;
public class StringMethods {
public static void main(String[] args) {
// TODO Auto-generated method stub
String A=" Monali";
[Link](3);
[Link]([Link](3));
[Link]('n');
[Link]([Link]('n'));
[Link](2);
[Link]([Link](2));
[Link]([Link](1, 4));
[Link](1, 4);
[Link]([Link](" Prashant"));
[Link]([Link]());
}
4)Why string mutable:
package StringInJava;
public class WhyStingMutable {
public static void main(String[] args) {
// TODO Auto-generated method stub
String a="Hello"; //String literal
String b="Hello"; //this will not create new string and will
refer to 'a' string
//[Link]("World");
//String c=[Link]("World");
//[Link](c);
String s=new String("Hello");
String s1=new String("Hello"); //"String class" will creates new
object every time in memory
[Link]([Link](b));
[Link](a==b);
[Link]([Link](s));
[Link](a==s); //Fail matching the references
[Link](s==s1); //fail references are different as
they are defined with "string class"
5)