Kotlinlearncs.online LogoJava
Return to List

Solve: Last Value From String

Created By: Geoffrey Challen
/ Version: 2022.7.0

Write a method name lastValueFromString that accepts a String containing one or more lines, each containing an integer value, and returns the last value as an Int. The values may have whitespace around them!

For example, given the String:

1
  2
4

You should return 4.

You can assume that the passed String contains at least one line, and has no blank lines or lines that do not contain an integer value.

Related Lessons

Stuck? You may find these lessons helpful: