• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Java 8 + Lambda  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is doing following code:

public class Main{

   public static void main(String[] args) {

       Arrays.asList(args).stream()
               .filter(s -> s.length()>=10)
               .map(s -> s.substring(0,10))
               .forEach(System.out::println);
   }
}
 
Saloon Keeper
Posts: 2086
76
Eclipse IDE Google Web Toolkit Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vadiks Charny wrote:What is doing following code...


Did you try it ?
Does it have any compilation error ?
Is the output not to your expectations ? (If yes, then please explain what you feel should have been the output)
 
salvin francis
Saloon Keeper
Posts: 2086
76
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And most importantly ...
Welcome to Coderanch  
 
Vadiks Charny
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No output for this code...
No compilation or other errors...
 
Bartender
Posts: 9559
189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

That code will only give any output if you supply command line parameters that are at least 10 characters long.

Can you show us the command you're using to run the application?
 
salvin francis
Saloon Keeper
Posts: 2086
76
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vadiks Charny wrote:No output for this code...


So, this answers my First and Second question, you did try it and you did not get any compilation errors. Now for my 3rd question..
Are you expecting no output ? (Stephan has given good hints about this)
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!