{
// instance variables - replace the example below with your own
private int i,a1,l,p,j;
/**
* Constructor for objects of class reverse
*/
public reverse()
{
p=0; // initialise instance variables
}
public void sampleMethod(String str)
{
l=str.length();
System.out.print(str);
for(i=0;i
char a=str.charAt(i);
/* System.out.print(a);*/
a1=(int) a;
if(a1==32 || i==l-1)
{
for(j=i;j>=p;j--)
{
char b=str.charAt(j);
System.out.print(b);
}
System.out.print(" ");
p=i;
}
}
}
}
No comments:
Post a Comment