1) Find the Merge point of two linked lists.
2) Swap two bits of integer.
3) Reverse individual words of the sentence.
4) Reverse string without using temp string.

Answer Posted / imran shaik

public class ReverseSentence {
public static void main(String[] args) {
System.out.println("please enter the Sentence");
Scanner input = new Scanner(System.in);
String s1 = input.nextLine();
String s[] = s1.split(" ");
String s3 = "";
int len = s.length;
for (int i = len - 1; i >= 0; i--) {
s3 = s3.concat(s[i]);
s3 = s3.concat(" ");
}
System.out.println(s3.trim());
}
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does snprintf return?

761


What is the implementation of destroy method in java. Is it native or java code?

716


Explain the public class modifier?

709


what is meant by encapsulation?

827


What is downcasting?

787


Name few java util classes introduced with java 8 ?

702


What is functional interface in java example?

760


Explain thread life cycle in java?

780


Can one thread block the other thread?

783


What is constant in programming?

759


what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread

772


Does java map allow duplicates?

656


What is garbage collection? Can it be forced to run?

745


Differentiate between class and structure.

804


Write java program to reverse string without using api?

737