Thursday, October 17, 2019

Time for JAVA #001

I want to learn. That is the first statement You have to understand to start. I found out a great site - exercism.io.
You can find there a lot of free exercises from many languages, and what is the most important You can consult your solution with a mentor.

Earlier today I finished one the execrises - named Reverse String.
The task was to write a code which will reverse a string for example: input: "cool" output: "looc".
Looks pretty easy but there are serveral ways to solve it.
In my opinion I found the simplest one:


The main issue of this problem is that String class does not have reverse() method, You need to convert the input string to StringBuilder, and after reversing You need to switch to String using toString().

I used gradle (please check it) for testing.


Back to Java is great!


No comments: