Frage im Vorstellungsgespräch bei Zalando

How to convert an Optional string to integer without throwing exception

Antworten zu Vorstellungsgespräch

Anonym

19. Jan. 2018

use filter and map

Anonym

5. Dez. 2018

Well its pretty basic. 1. Convert String into character array. 2. Check if Array's length = 48 && intValue <= 57) { int numValue = values[intValue - 48]; finalNumber += (numValue * Math.pow(10, power)); power--; } else { System.out.println("Not a number"); return; } } finalNumber *= multiplier; System.out.println(finalNumber); }

Anonym

5. Dez. 2018

Program ___________________________________________ int[] values = {0,1,2,3,4,5,6,7,8,9}; String test = "-123"; char[] arr = test.toCharArray(); if(arr.length = 48 && intValue <= 57) { int numValue = values[intValue - 48]; finalNumber += (numValue * Math.pow(10, power)); power--; } else { System.out.println("Not a number"); return; } } finalNumber *= multiplier; System.out.println(finalNumber); }

Anonym

5. Dez. 2018

glassdoor not allowing to post full code.