try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the continent;");
String CN = in.readLine();
String MaxDate="1";
for(Earthquakerecd e : eqList)
{
if( e.getContinent().equals("CN"))
{
MaxDate=e.getDate();
}
{
System.out.println( e.toString());
}
}
System.out.println( MaxDate);
}
catch (IOException e)
{
System.out.println("IOException has been caught");
}
This is a simple problem i think. In this problem Maxdate is declared as 1. CN is a string for continent . If the user input matches the continent , then the date should be passed from e.getDate() to Maxdate. In anycase , we should never get the output as 1 , it should be some date from object e. I am always getting 1 for Maxdate. Any possible solutions? is my syntax right?