0

how to find a set of any start location to between any last required location using lambdas

I am not familiar of this new java feature of lambda, I have an arraylist in generic class Location and I want to get a set of objects from a starting location (Object.element) to a specific location

   void find(){

      int Sindex;
      int Eindex;

      String stationName=(String)  to.getSelectedItem();// combo box
      String stationNameEnd=(String)  from.getSelectedItem();// get from combo box
      Controller manager=new Controller();

      manager.station.stream().forEach((entrySet) -> {
         if (entrySet.getStopName().equals(stationName)) {
             Sindex= manager.station.indexOf(entrySet);
             if(!entrySet.getStopName().equalsIgnoreCase(stationNameEnd)){
               dist=dist +    entrySet.getDistanceforlaststation();

               TolalPrice=TolalPrice+ entrySet.getPrice();
               Name=stationName;
               Name+=", "+ entrySet.getStopName();
               time= time+entrySet.getTime();
               point=point+entrySet.getPoints();
            }
        }
   });

Problem: I am not familiar of this new java feature of lambda

Case 1.1: I have an arraylist in generic class Location

Case 1.2: and I want to get a set of object

case 2: from find starting Object.element and

case 2.1: also stop to at specific location

What I have to do through lambda

CocoNess
  • 4,213
  • 4
  • 26
  • 43
HAROONMIND
  • 103
  • 7
  • What would your code look like without lambdas? – Louis Wasserman Dec 03 '14 at 07:24
  • I *think* what you're looking for are implementations of `skipUntil()` and `takeWhile()` on Java 8 Streams. Unfortunately, these are not supported natively in Java but there is 3rd party support. See this question: http://stackoverflow.com/questions/20746429/java-8-limit-infinite-stream-by-a-predicate – Mark Peters Dec 03 '14 at 07:25
  • thanks CocoNess for improve my question – HAROONMIND Dec 04 '14 at 07:33

0 Answers0