Note: (Restricted functionality due to obvious reasons!)
Minimal Code ( Raw-View ) :
class CRvrse
{
//String str = "Kuchh to hai";
String reverseStr(String s)
{
int len = s.length();
String st ="";
for(int i = len; i>0; i--)
{
st += s.charAt(i-1);
}
return st;
}
String stcut(String s, int fpos, int l)
{
String scut = "";
for(int f = fpos; f<=l; f++)
{
scut +=s.charAt(f); // - cut string until 'l'
}
scut = reverseStr(scut); // to reverse string here itself
return scut;
}
void strv(String str)
{
str = str.trim();
int first=0, last = str.length()-1;
String revStr="";
for(int i=0; i<=last; i++)
{
if((str.charAt(i) == ' ') || (i==last))
{
revStr += (stcut(str,first,i));
first=i;
}
}
System.out.println(revStr);
}
}
class ReverseWords
{
public static void main(String zee[])
{
String strM = "Kuchh to hai";
CRvrse obj = new CRvrse();
obj.strv("Bhukh Laggi Hai ! :(");
obj.strv(strM);
}
}