0
class String
{
public void main(String s)
{
String y;
y=" ";
int l=s.length();
for(int i=0;i<l;i++)
{
char c=s.charAt(i);
char g=s.chatAt(i+1);
if((c=='.')&&((g==' ')||(g>='A'&&g<='Z')))
{
System.out.println(y);
y=" ";
}
else if((c!='.')&&(g>='A'&&g<='Z'))
{
y=y+c;
}
}
}
}
(nt getng compiled)
{
public void main(String s)
{
String y;
y=" ";
int l=s.length();
for(int i=0;i<l;i++)
{
char c=s.charAt(i);
char g=s.chatAt(i+1);
if((c=='.')&&((g==' ')||(g>='A'&&g<='Z')))
{
System.out.println(y);
y=" ";
}
else if((c!='.')&&(g>='A'&&g<='Z'))
{
y=y+c;
}
}
}
}
(nt getng compiled)
abhishreya
Feb 08, '13
2 answers
1
You named your class as "String" which conflicted with the predefined String class. That was the major mistake.
I have commented the incorrect statements for you to see and understand where you did wrong.
The following code should work.
class Strings
{
public void main(String s)
{
String y;
y="";
int l=s.length();
// for(int i=0;i<l;i++)
for(int i=0;i<l-1;i++)
{
char c=s.charAt(i);
// char g=s.chatAt(i+1);
char g=s.charAt(i+1);
if((c=='.')&&((g==' ')||(g>='A'&&g<='Z')))
{
System.out.println(y);
y=" ";
}
else
{
y=y+c;
}
}
}
}
khanmansoor
Feb 08, '13
0
Log in to your account to answer this questions.