1 public class stringMeth { 2 public static void main(String[] args) { 3 String name = "Angkool"; 4 String number = "12345"; 5 6 // String result = name.concat("Angkool"); 7 // Connects two Strings 8 9 // char result = name.charAt(0); 10 //Prints out the Specific character indicated in the Index of the String 11 12 // int result = name.compareTo("ang"); 13 // Subtracts the number of Index of a String to Another 14 15 // boolean result = name.contains(); 16 // Checks if the String contains this character or Sentence is present in the String 17 18 // boolean result = name.equals("Angkool"); 19 // Checks if the Strin contains the same String that is inside the bracket it has to be complete 20 // Or else it will be false 21 22 // String result = name.replace('A','O'); 23 // Replaces a word or a character of a String 24 25 // String result = name.replaceAll("Ang","Tae"); 26 // Replaces a word or character of a String 27 28 // String result = name.toLowerCase(); 29 // Replaces All the String to a lowerCase 30 31 // String result = name.toUpperCase(); 32 // Replaces all the String to Uppercase 33 34 // int number2 = Integer.parseInt(number); 35 // Changes the String into a Integer 36 37 38 39 40 41 System.out.println(result); 42 43 System.out.println(number2); 44 45 } 46 47 }
1 import java.util.Scanner; 2 3 public class removeConsonants { 4 5 public static void main(String[] args) { 6 Scanner sc = new Scanner(System.in); 7 8 while(true){ 9 10 System.out.println("\tCONSONANT REMOVER"); 11 12 System.out.print("Enter Word: "); 13 String word = sc.nextLine(); 14 15 String newWord = removeCons(word); 16 17 System.out.println("Here is the Word Without Consonants: " + newWord); 18 19 } 20 } 21 22 23 public static String removeCons(String word) { 24 String newWord = " "; 25 char ch; 26 27 for(int i = 0 ; i < word.length(); i++) { 28 if(!isCons(Character.toLowerCase(word.charAt(i)))) { 29 ch = word.charAt(i); 30 newWord += ch; 31 } 32 } 33 34 return newWord; 35 } 36 37 public static boolean isCons (char c) { 38 String consonants = "bcdfghjklmnpqrstvwxyz"; 39 40 for(int i = 0; i < consonants.length(); i++) { 41 if(c == consonants.charAt(i)) { 42 return true; 43 } 44 } 45 return false; 46 } 47 }
1 import java.util.Scanner; 2 3 public class removeVowels { 4 public static void main(String[] args) { 5 Scanner sc = new Scanner(System.in); 6 7 while(true){ 8 9 System.out.print("Enter word: "); 10 String word = sc.nextLine(); 11 12 String finalWord = removeVowels(word); 13 14 System.out.println("Here is The Word without Vowels: " + finalWord.trim()); 15 16 } 17 18 } 19 20 public static String removeVowels (String s) { 21 String newWord = " "; 22 char ch; 23 24 for(int i = 0 ; i < s.length(); i++) { 25 if(!isVowel(Character.toLowerCase(s.charAt(i)))) { 26 ch = s.charAt(i); 27 newWord += ch; 28 } 29 } 30 31 return newWord; 32 } 33 34 public static boolean isVowel (char c) { 35 String vowels = "aeiou"; 36 37 for(int i = 0; i < vowels.length(); i++) { 38 if(c == vowels.charAt(i)) { 39 return true; 40 } 41 } 42 43 return false; 44 } 45 46 }
1 import java.util.Scanner; 2 3 public class upperCae_Last_Name { 4 public static void main(String[] args) { 5 Scanner sc = new Scanner(System.in); 6 System.out.println("\tUPPERCASE THE FIRST AND LAST NAME"); 7 8 System.out.println("Enter Full Name"); 9 String name = sc.nextLine(); 10 11 String[]newName = name.trim().split("\\s+"); 12 13 newName[0] = newName[0].toUpperCase(); 14 newName[newName.length -1]= newName[newName.length -1].toUpperCase(); 15 16 17 for(int i = 0 ; i < newName.length; i++) { 18 System.out.print(newName[i] + " "); 19 } 20 21 } 22 23 }