I got a question that I was not able to answer... Any help would be appreciated.
Question --> "Show a name and a region where the last letter of the name equals the last letter of the region."
I have tried to answer it but can't get it right.
static void oneLine(String name, String region,
int area, long pop, long gdp)
{
if (name.substring(name.length() - 1) == name.substring(region.length()-1))
{
System.out.println(name+" "+region);
}
}
How can I implement this?
Aucun commentaire:
Enregistrer un commentaire