Given a string, return true if the number of appearances of "is" anywhere in the string is equal to the number of appearances of "not"...
Search Results
Searching for: String
Individual Exercises
We'll say that a "triple" in a string is a char appearing three times in a row. Return the number of triples in the given string. The...
We'll say that a lowercase 'g' in a string is "happy" if there is another 'g' immediately to its left or right. Return true if all the...
Given a string, return the length of the largest "block" in the string. A block is a run of adjacent chars that are the same.
Given a string, look for a mirror image (backwards) string at both the beginning and end of the given string. In other words, zero or...
Given a string, return the sum of the numbers appearing in the string, ignoring all other characters. A number is a series of 1 or more...
Given a string, return a string where every appearance of the lowercase word "is" has been replaced with "is not". The word "is" should...
Given the name of a person and a phrase that person said, return a String
in the following format, including the quotation marks:
...
Given a String str
and a character ch
, return the number of times ch
appears in str
. For example, if str
is "Hello" and ch
is 'l', the...
Given an array of String
s, return a single String
that is made up of all strings in the array concatenated together in order. For...
Given an array of String
s, return a single String
that is made up of all strings in the array concatenated together in reverse order. For...
Given a String
, return an array of char
values that contains the characters of the string in reverse order. For example, if the string is...
Given two strings of equal length, return an array of char
values that contains the characters of the strings in alternating order. For...
Write a function in Java that uses recursion (no loops) to check if the String str
has any char a
. Return true
if it does and false
if it...
Create an enhanced for loop that iterates to each String in the array words
and returns true when there is at least one String with more...
Surround the appropriate lines of code with a try catch block so that first, an exception is caught when the String index is out of...
Create a method that returns the third character from the String word
. Be sure to use a try catch block and use the appropriate exception...
Considering the following lines of code, what will be the output?
try { String str = null; System.out.println(str.charAt(0)); }...
[Based on an exercise at https://codeworkout.cs.vt.edu/]
Given a string, return the string made of its first two chars, so the string...
You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't think he...
Given a class Answer<E>
, write a method that converts argument e
into String and returns that value. If the value is a primitve, (...
Octavia has given you a list of movies. She is tired of deciding what to watch by name and now wants to be able to pick them by the...
You are in charge of keeping student records. Those records are recorded in a hash map that uses a student's ID number as the key in...
Mars' new colony needs your help. This morning, a flurry of distress signals reached Earth, each encrypted with a secret message....
Given a string str
and an int n
, return a string made of the first n
characters of the string, followed by the first n - 1
characters of...