id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

srp4379@lausd.net 1-stringbasics > longestLength3
prev  |  next  |  chance

public int longestLength3(String s1, String s2, String s3)

Given THREE strings, return the length of the longer one.


  int len1 = s1.length();
  int len2 = s2.length();
  int len3 = s3.length();
  int longest = len1; // default, assume s1 is longer
  if (len2 > longest) { // test whether s2 is longer
    longest = len2;
  }
  if (len3 > longest) { // test whether s3 is longer
    longest = len3;
  }
  return longest;


longestLength3("1", "12", "123") → 3
longestLength3("012", "0123", "") → 4
longestLength3("hard", "day's", "night") → 5

...Save, Compile, Run (ctrl-enter)

public int longestLength3(String s1, String s2, String s3) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 5

Copyright Nick Parlante 2017 - privacy