If we compile the following code we will see 'country is already defined in myMethod()'
public class AlreadyDefinedSolution
{
public void myMethod()
{
String country;
String country="Bangladesh";// declared again
System.out.println(country);
}
}
Now the solution is to remove the declaration 'String' from the assignment statement.
public class AlreadyDefinedSolution
{
public void myMethod()
{
String country;
country="Bangladesh";//declaration removed
System.out.println(country);
}
}
0 comments:
Post a Comment