1.extract Vowels From String
1.extract Vowels From String
return vowels.toString();
}
Camel case is a naming convention where each word in a compound word is capitalized
except for the first word. To count the number of Camel Case characters in a given
string, you can iterate through the characters and count the uppercase letters that
are not at the beginning of the string. Here's a Java program that does that:
return count;
}
3. Reverse String: Write a Java program to reverse a given string without using any
library functions. For example, if the input is "hello", the output should be
"olleh".
int uniqueIndex = 0;
return uniqueIndex + 1;
}
5. Here's a Java program that counts the frequency of each character in a given
string using arrays and displays the result:
System.out.println("Character Frequency:");
for (int i = 0; i < 128; i++) {
if (frequencyArray[i] > 0) {
System.out.println("'" + (char) i + "': " + frequencyArray[i]);
}
}
}
6.
return digitOccurrences;
}
}
8. Given a string str of lowercase alphabets. The task is to find the maximum
occurring character in the string str. If more than one character occurs the
maximum number of time then print the lexicographically smaller character.
Output
Available at index 1
// First method
for (String i : arr) {
System.out.print(i + " ");
}
System.out.println();
// Second method
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}
System.out.println();
// Third method
int i = 0;
while (i < arr.length) {
System.out.print(arr[i] + " ");
i++;
}
System.out.println();
}
}
Output
Apple Banana Orange
Apple Banana Orange
Apple Banana Orange
import java.util.Arrays;
class GFG {
public static void main(String[] args)
{
String[] arr
= { "The", "quick", "brown", "fox", "jumps",
"over", "the", "lazy", "dog" };
// converting to string
String s = Arrays.toString(arr);
System.out.println(s);
}
}
Output
[The, quick, brown, fox, jumps, over, the, lazy, dog]
Sorting:
Sorting of String array means to sort the elements in ascending or descending
lexicographic order.
We can use the built-in sort() method to do so and we can also write our own
sorting algorithm from scratch but for the simplicity of this article, we are using
the built-in method.
import java.util.Arrays;
class GFG {
public static void main(String[] args)
{
String[] arr = { "Apple", "Cat", "Ball",
"Cartoon", "Banana", "Avocado" };
Output
Apple Avocado Ball Banana Cartoon Cat
public DynamicArray()
{
array = new int[1];
count = 0;
size = 1;
}
// function add an element at the end of array
size = count;
System.out.println();
System.out.println();
System.out.println();
Output
Elements of array : 1 2 3 4 5 6 7 8 9 10 11
No of elements in array : 11, Capacity of array :16
14. Certainly! Here's a Java program that checks the number of occurrences of each
digit in a series of strings using arrays:
return digitOccurrences;
}
}
15. WordCounter
return -1;