Untitled

mail@pastecode.io avatar
unknown
java
a month ago
935 B
173
Indexable
Never
public static int findlowerCaseVowelCount(String str){
        int len = str.length();
        int vowelCount = 0;

        for(int i=0; i<len; i++){
            char ch = str.charAt(i);

            if(Character.isLowerCase(ch) == true){
                if(ch == 'a' || ch == 'e' || ch == 'i' || ch=='o' || ch == 'u'){
                    vowelCount++;
                }
            }
        }

        return vowelCount;
    }

    public static void main(String[] args) {
        String s1 = "hello";
        String s1Intern = s1.intern();

        String s3 = new String("hello");
        String s3Intern = s3.intern();
        
        if(s1Intern == s3Intern){
            System.out.println("Yaya, we are equal");
        } else {
            System.out.println("We aren't equal");
        }

        StringBuffer s4 = new StringBuffer("Hi"); // mutable strings
        s4.append("yyy"); 

        System.out.println(s4);
    }
Leave a Comment