Calsoft Interview Question: reverse each word in a senten... | Glassdoor.ca

Interview Question

Developer I Interview(Student Candidate)

reverse each word in a sentence and make the first letter

  of the reversed words capital
Answer

Interview Answer

1 Answer

0

package com.test.demo;

public class ReverserString {

    public static void main(String[] args) {

        String str="Akash Phadtare Living In Saswad";

        String reverseString= "";

        String words[] = str.split(" ");

        for(int i=0;i=0;j--){
                char ch = word.charAt(j);
                tempString = tempString +ch;
            }
            if(i==0){
                reverseString = reverseString + tempString.toUpperCase()+" ";
            }
            reverseString = reverseString + tempString+" ";

        }
        System.out.println(reverseString);
    }

}

Akash on Sep. 15, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.