write a program in Java to take input name of the person and print the surname first and then name
Answers
Answered by
0
it's just a simple program
Answered by
0
public class prog { public static void main(String s) { s=s.trim();s=s+" ";String w="", ns=""; for(int i=0;i<=s.length();i++) { char ch=s.charAt(i); if(ch==" ") w=w+ch; else { if(i==s.length()-1) ns=w+" "+ns; else ns=ns+w+" "; } } System.out.println(ns); } }
Similar questions