Menu
Question Index
...

Create a word from the first letters of multiple words (2d char array). The words length might be different.

Input (2D Char array) Output (Char array)
{ { 'S', 'h', 'o', 'r', 't' }, {'M', 'e', 's', 's', 'a', 'g', 'e' }, {'S', 'e', 'r', 'v', 'i', 'c','e'} } {'S', 'M', 'S'}
{ {'N', 'o', 'r', 't', 'h'}, {'E', 'a', 's', 't'}, {'W', 'e', 's', 't'}, {'S', 'o', 'u', 't', 'h'} } {'N', 'E', 'W', 'S'}
{ { 'U', 'n', 'i', 't', 'e', 'd' }, { 'K', 'i', 'n', 'g', 'd','o','m' } } {'U', 'K'}



class CreateWordFromFirstLetters
{
    public static void main(String s[])
    {
        char multipleWords[][] ={
                            {
                                'M',
                                'a',
                                't',
                                'u',
                                'r',
                                'e'},
                        {
                                'E',
                                'f',
                                'f',
                                'e',
                                'c',
                                't',
                                'i',
                                'v',
                                'e'},
                        {
                                'R',
                                'o',
                                'b',
                                'u',
                                's',
                                't'},
                        {
                                'I',
                                'n',
                                't',
                                'e',
                                'l',
                    'l',
                                'i',
                                'g',
                                'e',
                                'n',
                                't'},
                        {
                                'T',
                                'r',
                                'a',
                                'i',
                                'n',
                                'i',
                                'n',
                                'g'}
                };
              
        char word[] = createWords(multipleWords);
        System.out.print("The word is " );
        for(char ch : word)
        System.out.print(ch + "");

    }


    public static char[] createWords(char[][] words)
    {
    }

}

Doubts

Problems

Topic: Learn Arrays And Loops

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App