Question

3. Write a method buildString which takes a 2D array of characters (char), and returns a string that is built from all the characters in that array. For example, the following method call should return hello! buildString( new char[] [ h, e,
0 0
Add a comment Improve this question Transcribed image text
Answer #1

public string buildString( char arr[][] )

{

    string ans = "";

   

    int i, j;

   

    // traverse the row

    for( i = 0 ; i < arr.Length ; i++ )

    {

        // traverse the columns

        for( j = 0 ; j < arr[i].Length ; j++ )

            // convert character to string

            ans += arr[i][j].ToString();

    }

   

    return 0;

}

Add a comment
Know the answer?
Add Answer to:
3. Write a method buildString which takes a 2D array of characters (char), and returns a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a method, strToArr, which takes one argument, aString , and returns a character array that...

    Write a method, strToArr, which takes one argument, aString , and returns a character array that represents the String. For example, strToArr("hi") should return {'h', 'i' }

  • Java programming: I need to create a method that is given a 2D char array and...

    Java programming: I need to create a method that is given a 2D char array and a String that returns a part of the original 2D array. The input string will tell the method which rows from the input array need to be returned. For example, a 5x5 char array input along with a string "0 4" would return rows 1 and 5 of the input array. The String input will always be numbers divided by spaces and will not...

  • Write a function called smallestLetter that takes in a string argument and returns a char. The...

    Write a function called smallestLetter that takes in a string argument and returns a char. The char that is returned by this function is the character in the string with the lowest ASCII integer code. For example: smallestLetter("Hello") returns ‘H’ which is code 72, and smallestLetter("Hello World") returns ‘ ’ (The space character) which is code 32

  • Write a method called printReverse() that takes a string and uses recursion to print the contents...

    Write a method called printReverse() that takes a string and uses recursion to print the contents of the string in reverse order. The string itself should not be reversed; it must be left in its original form. The method has the following header:   void printReverse(String s, int i) where s is a reference to the string, and i is an integer parameter that you may use as you see fit. You do not need to code up this method as...

  • Write a public static method named getMaxOf2Ints that takes in 2 int arguments and returns the...

    Write a public static method named getMaxOf2Ints that takes in 2 int arguments and returns the Maximum of the 2 values Write a public static method named getMinOf2Ints that takes in 2 int arguments and returns the Minimum of the 2 values Write apublic static method named getMaxOf3Ints that takes in 3 int arguments and returns the Maximum of the 3 values Write a public static method named getMedianOf3Ints that takes in 3 int arguments and returns the Median Value...

  • The code box below contains a live 2D rectangular array of characters (char) called someChars. Write...

    The code box below contains a live 2D rectangular array of characters (char) called someChars. Write a looping statement that allows you to calculate, and then print to the console, the number of entries in the array that are (lower case) 'x'. For example, if the array looks like this: x o o x y y y x p q The answer you enter should execute exactly one System.out.println statement. In Java please.

  • 11) Write a method (including header and body) that takes as an input an array of...

    11) Write a method (including header and body) that takes as an input an array of doubles and f three doubles containing the average, the maximum and the minimunm values of the input array. Test the program by calling the method from the main method. For example Input: 1 2 3 45 Output: 3 5 1 12) Write a Java method that takes a string as an argument and returns the reverse the string. Test the program by calling the...

  • Write a static method that takes an array of Strings and returns a double. Determine the...

    Write a static method that takes an array of Strings and returns a double. Determine the average number of characters for the Strings assigned to the array. Return the average.

  • package week_3; /** Write a method called countUppercase that takes a String array argument. You can...

    package week_3; /** Write a method called countUppercase that takes a String array argument. You can assume that every element in the array is a one-letter String, for example String[] test = { "a", "B", "c", "D", "e"}; This method will count the number of uppercase letters from the set A through Z in the array, and return that number. So for the example array above, your method will return 2. You will need to use some Java library methods....

  • Write a C++ console application that reverses an array of characters, and counts the number of:...

    Write a C++ console application that reverses an array of characters, and counts the number of:           Lower case characters (islower)           Upper case characters (isupper)           Digits (isdigit)           Other (not one of previous) Create four global variables to hold these counts. Create function void count(char input[], char reverse[]) that takes as input two arrays: one that contains characters and another that will contain the reverse of that array. The function will reverse the input array and do the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT