Computer Science, asked by adeogam04, 7 months ago

using
Write a prog. in java, in string (more than a word)
the string after editing as last word
display
will become first
Subash Chandra Bose
Output :Bose Subash Chandra
Input:Subash Chandra Bose​

Answers

Answered by SwapnilMehta
2

Answer:

import java.util.*;

class change

{

public static void main (String args [])

{

Scanner sc=new Scanner (System.in)

System.out.println("Enter the String");

String s=sc.nextLine();

int l=sc.length();

String s1,s2,s3;

int pos1=s.IndexOf(' '); //1st space

int pos2=s.lastIndexOf(' '); //last space

s1=s.subString(0,pos1);

s2=s.subString(pos1,pos2);

s3=s.subString(pos2,l);

String ans= s3+" "+s1+" "+s2;

System.out.println("Edited String="+ans);

}

}

Subscribe My Youtube Channel Study To Study ICSE-Swapnil Mehta for more Java Programs

Explanation:

Hope this will help you

Please mark me as brainlist :)

Similar questions