class str
{
public static void main(String args[])
{
String s="this is lecture class";
char temp;
String a[]=s.split(" ");
System.out.println("..........the String are ...... ");
for(int i=0;i<a.length-1;i++)
{
System.out.print(" "+a[i]);
}
System.out.println(" ");
for(int i=0;i<a.length-1;i++)
{
char p[]=a[i].toCharArray();
for(int j=0;j<p.length-1;j=j+2)
{
temp=p[j];
p[j]=p[j+1];
p[j+1]=temp;
}
a[i]=new String(p);
}
System.out.println("..........the String after interchange of character ...... ");
for(int i=0;i<a.length-1;i++)
{
System.out.print(" "+a[i]);
}
}
}
{
public static void main(String args[])
{
String s="this is lecture class";
char temp;
String a[]=s.split(" ");
System.out.println("..........the String are ...... ");
for(int i=0;i<a.length-1;i++)
{
System.out.print(" "+a[i]);
}
System.out.println(" ");
for(int i=0;i<a.length-1;i++)
{
char p[]=a[i].toCharArray();
for(int j=0;j<p.length-1;j=j+2)
{
temp=p[j];
p[j]=p[j+1];
p[j+1]=temp;
}
a[i]=new String(p);
}
System.out.println("..........the String after interchange of character ...... ");
for(int i=0;i<a.length-1;i++)
{
System.out.print(" "+a[i]);
}
}
}
No comments:
Post a Comment