Frage im Vorstellungsgespräch

Vorstellungsgespräch für eine Beschäftigung als Senior Software Engineer

-Berlin, Berlin

Zalando

How to convert an Optional string to integer without throwing exception

Antwort

Antworten zu Vorstellungsgespräch

4 Antworten

0

use filter and map

Anonym am

0

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); }

Monis Yousuf am

0

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); }

Monis Yousuf am

0

glassdoor not allowing to post full code.

Anonym am

Antwort oder Kommentar posten

Um dies zu kommentieren, bitte anmelden oder Konto anlegen.