Skip to main content
change code from method to lambda
Source Link

Java 8, 57 bytes (9470 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

Thanks to LukeStevens for pointing out to use lambdas to be more golfy.

String b(String[] a){return Arraysw->Arrays.stream(aw).max(Comparator.comparing(String::length)‌​).get();}

Java 8, 57 bytes (94 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

String b(String[] a){return Arrays.stream(a).max(Comparator.comparing(String::length)).get();}

Java 8, 57 bytes (70 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

Thanks to LukeStevens for pointing out to use lambdas to be more golfy.

w->Arrays.stream(w).max(Comparator.comparing(String::length)‌​).get()

changed program to be a function
Source Link

Java 8, 57 bytes (7294 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

String b(String[] a){return Arrays.stream(a).max(Comparator.comparing(String::length)).get();}

Java 8, 57 bytes (72 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

return Arrays.stream(a).max(Comparator.comparing(String::length)).get();

Java 8, 57 bytes (94 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

String b(String[] a){return Arrays.stream(a).max(Comparator.comparing(String::length)).get();}

deleted 2 characters in body
Source Link
Steadybox
  • 16.5k
  • 5
  • 41
  • 84

JAVA 8, 57 bytes (72 bytes)

Java 8, 57 bytes (72 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

return Arrays.stream(a).max(Comparator.comparing(String::length)).get();

JAVA 8, 57 bytes (72 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

return Arrays.stream(a).max(Comparator.comparing(String::length)).get();

Java 8, 57 bytes (72 bytes)

By the power of streams, my java answer shall be the shortest

Arrays.stream(a).max(Comparator.comparing(String::length))

Honestly I don't know if I cheated with that answer because I don't return anything but you could use that line of code. If we really want to return stuff then it's a bit longer.

return Arrays.stream(a).max(Comparator.comparing(String::length)).get();

Source Link
Loading