Java Class
Java Class
1.REVERSE A STRING
public class demo1 {
public static void main(String args[]) {
demo1 d = new demo1();
System.out.println(d.rev("hello"));
}
return s1;
2.consider only the alphabets and give the number of vowels and consonants present in the given string
no special characters should be considered
public class demo1 {
public static void main(String args[]) {
demo1 d = new demo1();
d.num("he#$^^$4llo");
}
if(s==null) {
System.out.println("no of vowels = 0 and consonents =0");
return; // comes out of the method
}
int v = 0;
int c=0;
s = s.toLowerCase();
// wihout array
public boolean num(String s ) {
// array of banned words
if (s.contains("hatefull") || s.contains("bad") ||
s.contains("ugly")) {
return true;
}
else return false;
}
// using array
}
}
4.palindrome of a string
}}
System.out.println(d.otp("123"));
}
}}
Method 2
public class demo1 {
public static void main(String args[]) {
System.out.println(d.otp("123"));
}
return true;
}}
*************************************************************************************
*************************************************************************************