Ad
Code
Diff
  • public class NamesAndNumbers{
      
      public static String run(int[]numbers, String[] names){
        String outputValue = "error";
    		if(numbers == null || names == null) {
    			return "array is null";
    		} else if(numbers.length == 0 || names.length == 0) {
    			return "length is zero";
    		}
    		return outputValue;
      }
      
    }//end class.
    • public class NamesAndNumbers{
    • public static String run(int[]numbers, String[] names){
    • return "";
    • String outputValue = "error";
    • if(numbers == null || names == null) {
    • return "array is null";
    • } else if(numbers.length == 0 || names.length == 0) {
    • return "length is zero";
    • }
    • return outputValue;
    • }
    • }//end class.

Given an array of strings and an array of ints, associate them from longest to shortest according to the length of each string. The output format must be a string with the syntax:

  • name1:number1,name2:number2,name3:number3... nameN:numberN
    Input example:
  • String[]names = {"Ana", "Miguel", "Josemanuel"}
  • int[]numbers = {1034, 21, 537}
    Output example:
  • "JoseManuel:1034,Miguel:537,Ana:21"
public class NamesAndNumbers{
  
  public static String run(int[]numbers, String[] names){
    return "";
  }
  
}//end class.