Αποτελέσματα Αναζήτησης
String key = "a"; System.out.println ("The character "+ key+ " is in the String "+ word + ": " + findChar (word, key)); } public static boolean findChar (String string, String key) {. // Write a more efficient version of isChar than the one in the exercise description. // Use the hint!
- apcsa-codehs/unit-4/4.5/improving-findchar-speed.java at master ...
public static boolean findChar (String string, String key)...
- apcsa-codehs/unit-4/4.5/improving-findchar-speed.java at master ...
public static boolean findChar(String string, String key) // Write a more efficient version of isChar than the one in the exercise description // Use the hint!
public static boolean findChar (String string, String key) // Write a more efficient version of isChar than the one in the exercise description // Use the hint!
String word = "This is a sentence"; String key = "a"; System. out. println ("The character "+ key+ " is in the String "+ word + ": ". + findChar (word, key)); } public static boolean findChar (String string, String key) {. // Write a more efficient version of isChar than the one in the exercise. description.
SPOILER. 4.5.9: findChar Speed Reflection (Solution) I believe that the first method is more efficient as it takes less space and time to write and still executes. I believe that the first method ir more efficient since the execution count was lower.
public static boolean findChar(String string, String key) for(int index = 0; index < string.length(); index++) String character = string.substring(index,index+1);
Study with Quizlet and memorize flashcards containing terms like 4.5.6: Time Comparisons, 4.5.7 Improving findChar Speed, 4.5.9: findChar Speed Reflection and more.