java - IntStream strange error -


java 8 has new interface, named intstream. used of() static method , encountered strange error:

this static method of interface intstream can accessed intstream.of

but can see in following code, i, exactly, used intstream.of

import java.util.stream.intstream;  public class test {      public static void main(string[] args) {         int[] listofnumbers = {5,4,13,7,7,8,9,10,5,92,11,3,4,2,1};         system.out.println(intstream.of(listofnumbers).sum());     }  } 

moreover, if check api, see method has been declared in similar way used.

although intstream.of(int...) seems work more expected use arrays.stream(int[]).

public void test() {     int[] listofnumbers = {5, 4, 13, 7, 7, 8, 9, 10, 5, 92, 11, 3, 4, 2, 1};     // works fine designed ints instead of int[]s.     system.out.println(intstream.of(listofnumbers).sum());     // expected use.     system.out.println(intstream.of(5, 4, 13, 7, 7, 8, 9, 10, 5, 92, 11, 3, 4, 2, 1).sum());     // better approach int[].     system.out.println(arrays.stream(listofnumbers).sum()); } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -