Old question, new answer (for Java 8)
IntStream.range(0, 10).forEach(n -> System.out.println(n));
or with method references:
IntStream.range(0, 10).forEach(System.out::println);
Related Contents:
- i cant get my calculator to work
- How to get X and Y index of element inside GridLayout?
- How do I call one constructor from another in Java?
- What is the recommended way to escape HTML symbols in plain Java?
- How to ensure order of processing in java8 streams?
- Create array of regex matches
- How to parse XML using the SAX parser
- What is the Java equivalent for LINQ? [closed]
- Making a robust, resizable Swing Chess GUI [closed]
- Why doesn’t Java offer operator overloading?
- How to unzip files programmatically in Android?
- When exactly do you use the volatile keyword in Java? [duplicate]
- JUnit testing with simulated user input
- How do I preserve line breaks when using jsoup to convert html to plain text?
- How can I write a Java application that can update itself at runtime?
- Leaking this in constructor warning
- Why does a Try/Catch block create new variable scope?
- Efficient swapping of elements of an array in Java
- Why is an instance variable of the superclass not overridden by a subclass?
- What does it mean to program to an interface?
- java.lang.NoSuchMethodError: javax.servlet.ServletContext.getContextPath()Ljava/lang/String;
- nextDouble() throws an InputMismatchException when I enter a double
- Exception using HttpRequest.execute(): Invalid use of SingleClientConnManager: connection still allocated
- Why are strings immutable in many programming languages? [duplicate]
- Selenium switch focus to tab, which opened after clicking link
- ConcurrentModificationException when adding inside a foreach loop in ArrayList [duplicate]
- Calling a java method from c++ in Android
- How do I fix a compilation error for unhandled exception on call to Thread.sleep()?
- How to hash some String with SHA-256 in Java?
- Classpath resource within jar
- Read XLSX file in Java [closed]
- Java overloading rules
- What does System.in.read actually return?
- Is it possible to add Legend to the plot in JFreeChart?
- java.lang.NoClassDefFoundError: javax/mail/Authenticator, whats wrong?
- Query a JSONObject in java
- Setting up enviromental variables in Windows 10 to use java and javac
- Busy loop in other thread delays EDT processing
- How to keep my user input on the same line after an output?
- URLConnection getContentLength() is returning a negative value
- How can I show ellipses on my TextView if it is greater than the 1 line?
- Sort a file with huge volume of data given memory constraint
- Why use finally
- Package structure for a Java project?
- android camera : Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity
- How do I iterate through the id properties of R.java class?
- Will Java Final variables have default values?
- How do you set a value to null with org.json.JSONObject in java?
- Is it a good practice to use Optional as an attribute in a class? [duplicate]
- Android firewall with VpnService