Quick Tip |Java 8 |This static method of interface Stream can only be accessed as Stream.of


This is very basic error when new to Java 8.

For this simply cross check that compilation version for is set to Java 8 in your IDE.

If you don’t know above step, then follow the steps:

  1. Create Java class.
  2. Paste this code-    public static void main( String[] args )    {Stream<Integer> stream = Stream.of(1,2,3,4,5,6,7,8,9);

    stream.forEach(p -> System.out.println(p));


  3. Hover on error. IDE will ask you to change compilation version to Java 8.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s