java - How to split a string into an integer array? -


how can split string integer array without using loops?

for example:
if have string "12345" , wanted converted int array [1,2,3,4,5] without using loop. know how way. there built-in function java provides splits , converts desired data type?

if java 8 use stream:

"a sequence of elements supporting sequential , parallel aggregate operations."

observe:

import java.util.arrays; import java.util.stream.stream;  class main {   public static void main(string[] args) {     string numbersstring = "12345";      int[] numbersintarray = stream.of(numbersstring.split("")).maptoint(integer::parseint).toarray();       system.out.println(arrays.tostring(numbersintarray)); // [1, 2, 3, 4, 5]   } } 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -