java - how do i write this method that returns the larger string? -


i new programming (java) , our teacher asks make excercises in programming lab.

now can't seem find out how write correct method. question: write method max has 2 string parameters , returns larger of two.

i have

string string1, string2; public max strings(string1.length(), string2.length()) {     if (string1.length()>string2.length)     {     return string1;     else if (string1.length()<string2.length)         return string2;     } } 

public string max(string a, string b) {     return (a.length() > b.length()) ? : b; } 

there condition both strings of equal length not tested for, null , empty strings,


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -