Computer Science, asked by panjwanialif786, 1 year ago

Write a program in java to enter a String and print palindrome words present in the string

Answers

Answered by Anonymous
9

CODE :


import java.util.*;


class reverse_string

{


public void main()


{


Scanner sc=new Scanner(System,in);


System.out.println("Enter a sentence");


String s=sc.nextLine();


s=s+" ";


String rev="";


int l=s.length();


String w="";


for(int i=0;i<l;i++)


{


char ch=s,charAt(i);


if(ch!=' ')


{


w=ch+w;


}


else


{


System.out.print(w+" ");


w="";


}


}


}


}



OUTPUT :


Enter a sentence

Hope to die


eid ot epoh



That's the code hope it helps !

____________________________________________________________________


agarwalmuskan442: this is incomplete but right
Similar questions