Lesson 1-1 code is correct?

Hi all.

I just started watching a course and have finished all the chapters of lesson 1, no homework and quiz.

So we in Lesson 1-1 example usage of lambda expressions (with my method createStudentsList() to fill the list):

Students list < student > = createStudentsList();

Double highestScore = 0.0;

for (s student: students) {}

If (s.getGradYear () == 2011) {}

If (s.getScore () > highestScore) {}

highestScore = s.getScore ();

}

}

}

It compiles and works.

But the proposed changes by using lambda expressions does not work:

Students list < student > = createStudentsList();

Double highestScore = student

filter (new predicate < student > () {})

public boolean test (Student's t) {}

return t.getGradYear () is 2011;

}

})

.map (Mapper new student, < Double > () {})

public Double extracted (student s) {}

Return s.getScore ();

}

})

. Max();

saying "the filter method (new predicate < student > () {}) is undefined for the type List < student >" and "Mapper cannot be resolved to a type.

Even the latest version of the code does not compile:

Students list < student > = createStudentsList();

highestScore = student

filter (student s-> s.getGradYear () == 2011)

.map (student s-> s.getScore ())

. Max();

with "syntax error, insert ';' to complete the statement" for the two statements of student.

I managed to make it work with this approach:

Students list < student > = createStudentsList();

Double highestScoreL = student

. Stream()

filter (s-> s.getGradYear () == 2011)

.mapToDouble (s-> s.getScore ())

. Max()

. getAsDouble();

I do wrong or just missed sth sth important? Sorry for the question so long - it is because as pieces of code .

BTW I use Eclipse March 4.5.0 and jdk1.8.0_51 if that matters.

There is problem with your code. I fixed your code and it would be:

Student s0 = new Student(2014, 685);

Student s1 = new Student(2014, 675);

Student s2 = new Student(2014, 635);

Student s3 = new Student(2014, 985);

List of students of = Arrays.asList (s0, s1, s2, s3);

Stream studentStream;

studentStream = students.stream ().

filter (new predicate() {}

@Override

public boolean test (Student's t) {}

return t.getGradYear () is 2014;

}

});

Stream highestScoreStream = studentStream.map (new function() {}

@Override

public Double apply (student s) {}

Return s.getScore ();

}

});

HighScore = highestScoreStream.max of in option (new comparator() {}

@Override

public int compare (Double d1, d2 Double) {}

Return d1.compareTo (d2);

}

});

Double highestScore = highScore.get ();

System.out.println (highestScore);

Make sure and tell me if you don't get anything. This is the detailed code pre JDK8 average. Now you can write it as functional programming.

and Yes... The video code is just for us to understand. It is not syntactically correct as map is not a FunctionalInterface in JDK8.

Tags: Java

Similar Questions

  • Hi can someone tell me how to get in touch with microsoft to check if my code is correct

    Hi all can someone tell me how I can contact microsoft to varify my coa is for the correct version of windows that the coa sticker worn if wrong that only the code itself is visible please help

    If the certificate of authenticity is attached to a computer, you must contact the manufacturer of this computer using.

  • Could someone please check my code is correct and clean

    Hello

    I bought a template and it handled for my site, could someone please check my code to make sure I have it correct. Because what I do here I will duplicate for the rest of the page.

    < class li =' same illustration portfolio-entry ">"

    < img src = "images/portfolio thumbnails/illustration & fashion/1_britten.jpg" width = "220" height = "240" alt = 'Britten Motorcycle Illustration' >

    < div class = "entry-inch standard" > < a class = "thumblink" href = "images/portfolio images - news/illustration & fashion/1_britten_lge.jpg" rel = "prettyPhoto [2376]" >

    < img src = "images/portfolio thumbnails/illustration & fashion/1_britten.jpg" alt = "Britten Motorcycle Illustration" class = "portfolio category" > < span class = 'extra' > < / span > < /a > < / div >

    < div class = "entry-title" > Web </span > < span > < a title = "Permanent link Soft store" rel = "bookmark" > Britten Motorcyles < /a > < / div >

    < a class = "more-link" href = "images/portfolio images - news/illustration & fashion/1_britten_lge.jpg" rel = "prettyPhoto [2376]" > < span > </span > < /a > < /li > Design view

    This line, I don't want the text to a link anywhere:

    < div class = "entry-title" > Web </span > < span > < a title = "Permanent link Soft store" rel = "bookmark" > Britten Motorcyles < /a > < / div >

    Web site: www.lorraines.co.nz

    Thanks in advance

    You can check your code with the following online tools:

    CSS - http://jigsaw.w3.org/css-validator/

    HTML - http://validator.w3.org/

    Nancy O.

    ALT-Web Design & Publishing

    Web | Graphics | Print | Media specialists

    http://ALT-Web.com/

  • Is this a bug in Dreamweaver? Because the code is correct! Please advise!

    Hey coders.

    I'm pretty new to Dreamweaver, but have a decent understanding of the code and if I ever got stuck I usually figure out on my own, but today are not the case.

    My problem is: when I enter the code it didn't display correctly in my workspace, the slice falls completely down, when it should have been in the middle. But when I make it with the browser, it displays correctly! ???

    You can see my site here's progress to:

    http://www.topvizstudio.com/webproblem/index.html

    or you can download sliced HTML and Image here:
    http://www.topvizstudio.com/webproblem/index.html

    Please help, it is just killing me, I've already lost 2 hours trying to figure it out!

    Thank you!

    -Sergehttp://www.topvizstudio.com/webproblem/sample.jpg

    Design view is not 100% reliable.  What matters most is how your pages make in all the major browsers (IE 6,7,8, FF, Opera, Safari/Chrome...)

    The last picture is 500px wide and floating to the left, and yet the previous images are quite a bit more small. This leads me to think there isn't enough available on the page width to account for this installment.

    In addition, I do not understand why you are using may inline styles both in your HTML code.  This will make it much more difficult lifestyle changes later because your styles are not separated from the content.

    You must delete a semicolon after your image file names.

    Finally, your code has a typical beginner problem called division-it is.  In contrast to the provisions based on a table where each element is contained in a table cell, CSS layouts, there is no need to place each element on the page within its own division. In fact, it is often best if you do not.  Less increase in the code.

    Review this 3-part tutorial. I think it will help you.

    Taking  a Fireworks (or Photoshop) comp to a CSS based layout in DW

    http://www.Adobe.com/devnet/Fireworks/articles/web_standards_layouts_pt1.html

    Nancy O.
    ALT-Web Design & Publishing
    Web | Graphics | Print | Media specialists
    http://ALT-Web.com/
    http://Twitter.com/ALTWEB
    http://ALT-Web.blogspot.com

  • Change attached code and corrections

    In VI I joined, there are two questions that my research director and I want to speak to, but are not enough familiar with the code to be able to change it compitently, we are not quite familiar with LabView to code from scratch.

    The first question, it is the incrimentation system works on tension of start, end, Incriment voltage and time of incriment.

    E.g. = 0.00 starting voltage

    End of voltage = 5.00

    Incriment = 0.01

    Time of incriment = 1.00 s

    This will result in 500 incriments, each incriment taking 1 seconds, for a total run of 500 seconds time. We, however, do not use real tensions, but are instead using this system of incrimentation as a means to load the program on data points how much to take and for how long.

    Is not our doing, but just how the program was created originally (my supervisor has received the code elsewhere and has no contact with those who, when he received it). We would prefer the code to run simple on a loop For or a loop so that we can run out for as long as we will work without the help of an incrimentation tension system (because the system voltage does not end voltage value more than 10v regardless of the absence of real tension applied.) If someone has an idea how this could be done, the Council would be wonderful.

    The second question is a little bug that occurs every time that the data are taken. Whenever the chart 1 receives a data point, the first data point that it receives in any period of data collection is copied on 3 other cards. This should not be the case, as the 3 other cards are not representations of data that should be coming in the first table, and come from different sources entirely. I have reviewed the block diagram, but I am a novice when it comes to LabView and could find no explanation.

    If someone saw to the subject or the other of these issues with the VI I enclose below, help would be greatly appreciated.

    Thank you Stevem181 and MoReese. Your advice has been invaluable

    Now, the code runs exactly as I love to run and is more clean and easy to navigate. Thanks to you two

  • HOW can I get the code for CORRECTION of ERROR 39?

    IM really hoping that someone out there in PC-land can help!

    I have a problem with my CD/dvd-rom drive.

    the D of DVD LITE-ON LH-16D1P ATA device' installed when I bought my PC has the yellow triangle on him when I access my device manager.

    the driver provider is "MICROSOFT", but because the software has been installed by 'SOME ONE at COLLEGE' they cannot help me find a solution!

    the device status says "Windows cannot load the driver for this hardware device. The driver may be corrupted or missing. (Code 39) »

    When I try to "Update Driver Software" for this unit and research online, I get a message that reads "best driver for your device is already installed, Windows has fix6 software driver for your device is up-to-date."!

    Help me!!

    Cheers.

    Evan

    Hello

    Code 39 means that the driver is corrupted or missing.

    Please make all below even if you have done some before as it is often the set of operations which solves
    the question.

    Try this - Panel - Device Manager - CD/DVD - double-click on the device - driver tab - click
    Update the drivers (this will probably do nothing) - then RIGHT click the drive - UNINSTALL - REBOOT
    This will refresh the default driver stack. Even if the reader does not appear to continue below.

    Then, work your way through these - don't forget the drive might be bad, could be a loose cable or
    slight corrosion on the contacts (usually for a laptop) and other issues.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs
    http://support.microsoft.com/kb/314060 - a Mr Fixit

    The CD drive or the DVD drive does not work as expected on a computer that you upgraded to Windows Vista
    http://support.Microsoft.com/kb/929461

    When you insert a CD or a DVD, Windows Vista may not recognize the disc
    http://support.Microsoft.com/kb/939052

    Your CD or DVD drive cannot read or write media - A Mr Fixit
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    CD/DVD drive does not appear in Windows Vista, or you receive this error during the installation of Windows Vista after booting from the DVD (AHCI)
    http://support.Microsoft.com/kb/952951
    Drive CD - R or CD - RW Drive is not recognized as a recordable device
    http://support.Microsoft.com/kb/316529/

    Hardware devices not detected or not working - A Mr Fixit
    http://support.Microsoft.com/GP/hardware_device_problems

    Another possibility is that the cables are loose. Remove ALL power, then make sure that the cables in both
    ends. Remove and replace, do not just tight. For laptops, you can often clean power and
    contacts data with a pencil eraser.

    --------------------------------------------------------------

    Also check with your system manufacturer to see if there are any updated drivers for your DVD. Or even if it
    are you can reinstall the 'old'. Many use Windows default drivers however some special aura
    ones. Also check the website of the manufacturer of the car.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    Hope these helps.
    Rob - bicycle - Mark Twain said it is good.

  • Code works correctly with sql developer but not in shapes

    Hi, formulas [32 bit] Version 6.0.8.11.3 (Production)

    INSERT INTO DEFICIENCIES 
    
    SELECT I.ITEM_ID , S.ITEM_ENG_NAME , S.ITEM_ARABIC_NAME 
    FROM ITEM_DETAIL I , STOCK S 
    WHERE I.ITEM_ID = S.ITEM_ID 
    AND I.ITEM_ID NOT IN ( SELECT ITEM_ID FROM DEFICIENCIES )
    GROUP BY I.ITEM_ID , S.ITEM_ENG_NAME , S.ITEM_ARABIC_NAME 
    HAVING MAX(EXPIRY_DATE) <= TRUNC(SYSDATE)
    OR SUM(QUANTITY) = 0 
    UNION
    SELECT E.ITEM_ID , S.ITEM_ENG_NAME , S.ITEM_ARABIC_NAME 
    FROM EXPIRED E , STOCK S 
    WHERE E.ITEM_ID = S.ITEM_ID 
    AND E.ITEM_ID NOT IN ( SELECT ITEM_ID FROM DEFICIENCIES )
    ORDER BY ITEM_ENG_NAME ;
    

    When I used it in oracle forms, I have faced

    error 103 at line 15 column 2
    encountered the symbol "order" when expecting one of the following: 
    ;return RETURNING_ adn or group havign intersect minus start union where connect 
    the symbol "group was inserted before "order" to continue
    
    

    ?

    forms not authorized such use for «insert into...» Select... Of...  ORDER BY' with order by.

    but this use can be used in a database procedure.

    write your code in a database procedure.  your code will run.

  • PIVOT in oracle - Code of Correction

     select * from 
                  (
                    select prod_code from UNICA.DSI_SUBS_STOP_START_DRW
                   )
    pivot  (
         count(prod_code)
         For prod_code in ('E','3','W','W5','SS','S','4','W2','WS','3S','D','FS','3T','H3','TS')
              ) 
    I can't make this pivotal work. Can someone fix my error in the code. I get error "Command not properly ended SQL". I have a problem, to operate the PIVOT. Oracle 10 g support ROTATE at all?

    Thank you.

    Prior to version 11, you would do:

    select count(case when prod_code = 'E' then 'X' end) as PROD_CODE_E
         , count(case when prod_code = '3' then 'X' end) as PROD_CODE_3
         , count(case when prod_code = 'W' then 'X' end) as PROD_CODE_W
         , ...
         , count(case when prod_code = 'TS' then 'X' end) as PROD_CODE_TS
    from unica.dsi_subs_stop_start_drw
    ;
    
  • My code is correct by flash tells my other wise?

    I use a Lynda.com video and flash tells me that there are errors in my code?

    THE FOLLOWING ARE THE ERRORS:

    FunButtons.as, Line14 1013: Attribute private may be used only on class property definitions.

    FunButtons.as, Line20 1013: Attribute private may be used only on class property definitions.

    MY FILE

    package

    {

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    /public class FunButton extends MovieClip

    {

    public void FunButton()

    {

    this.addEventlistener (MouseEvent.ROLL_OVER, grow)

    this.addEventlistener (MouseEvent.ROLL_OUT, shrink)

    }

    }

    grow(event:MotionEvent):void private function

    {

    this.scaleX = 1.5;

    this.scaleY = 1.5;

    }

    shrink(event:MotionEvent):void private function

    {

    this.scaleX = 1;

    this.scaleY = 1;

    }

    }

    use:

    package

    {

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    SerializableAttribute public class FunButton extends MovieClip

    {

    public void FunButton()

    {

    this.addEventlistener (MouseEvent.ROLL_OVER, grow)

    this.addEventlistener (MouseEvent.ROLL_OUT, shrink)

    }

    //}

    private void grow(event:MotionEvent):void

    {

    this.scaleX = 1.5;

    this.scaleY = 1.5;

    }

    private void shrink(event:MotionEvent):void

    {

    this.scaleX = 1;

    this.scaleY = 1;

    }

    }

    }

    p.s. these MotionEvents should be MouseEvents

  • Lesson 4-2 homework: howto correctly complete the loop of acceptAndOpen()?

    Hello

    I created a thread with a while loop that contains a call to acceptAndOpen(), as described by Jim.

    Now, I put an end to this thread in the MIDlet destroyApp() function.

    Since acceptAndOpen() blocks the thread a Boolean variable to control the while loop does not help.

    How am I supposed to wake up call blocking acceptAndOpen()?

    Any help is appreciated

    Ralf

    Hi Ralf,.

    Worldwide Java ME Thread.interrupt () is not considered to be an adequate solution. There are the following precautions for Thead.interrupt () in the CLDC spec:

    In an implementation meets the CLDC specification, this operation is not necessary to cancel or clean operations of e/s in waiting that the thread can be expected.

    As I said, the right way is to close the stream

    Kind regards

    Andrey

  • Correct to redirect to an ssl certificate code

    I need to know if this code is correct for my Web site forwarding to an ssl certificate: < meta http-equiv = "refresh" content = "0; "URL ="https://ineedmylicense.com/index.html"" / > if this is correct, where in the header should I place this line of code and do I need to place it on each page of the Web site? Thanks in advance.

    Issue edited by moderator for clarity

    Here is a ready made copy of .htaccess html5-past-everywhere/.htaccess at h5bp/html5-past-everywhere from master · GitHub. He is ready with the feature you want to well in the original version, it is commented out. If your remove the comment marks ("#") to 352 to 356 lines, then you will have a working version. Simply place the file in the root directly and everything's fine.

    Moreover, I assume that you run an Apache server rather than by a Windows Server.

  • Does anyone know what code error on a classic 160gig 1429? boot woot, woot connect to the mac, iTunes, restoration of woot

    160g iPod classic my wife completely. get it connected once tried a restore toure has failed with an error code 1429, followed not to recommend it than apple, no chance and now it does not connect to mac (iTunes) so can't do anything. If I knew what means the code, perhaps correct or those it and buy a replacement it, wish they still made the classic.

    Take a look at Re: corrupted iPod classic. What are the stats?

    TT2

  • communication of the PSC-1804 by PSC-2220 blocking code RT

    I'm trying to communicate to a PSC-HAVE-100 on a PSC-1804 through a PSC-2220.  I got it for several months with many updates/revisions of the labor code and then the PVD code start correctly (code falls down during the first iteration and cfp-2220 flashes an orange status light).  I followed the cause up to the FP Read VI to the PSC HAVE 100.  The code crashes even with a simple reading of FP in a while loop (I posted a snip it code), other modules of read/write without problem.  If I run the code without the 1804 connected to the network, the code runs without problem.  I tried several different 1804 s, 2220, modules of I, paraphernalia of ethernet, host PC, versions of code, backplanes, etc, software versions. I tried to go back to previous versions of my code, but even those who no longer work.  I am at a loss.

    Current software/firmware

    firmware of 1804 - 6.05 (I also tried 6.08 I found the link in a forum, why is it not on the download page of NOR?)

    2220 software - Fieldpoint 6.09 - August 2011

    LabVIEW 2011

    Windows 7 Enterpirse

    I work with Drew and thought I would give some info in case anyone else has this problem.  What we found was that somehow, the configuration of the controller became out of sync compared to what we had in the project.  In general, use us ftp to put the new version of the controller (PSC-2220).  If the configuration of e/s in the project has not changed this works very well.  However, if you add / remove a module or change the channel names, you will need to re - deploy the project e/s settings.  I think the other thing that can ruin is if you open MAX for troubleshooting & auto discover material.  It uses the default channel names, then it asks you to save when you exit & default settings are downloaded to the controller.  The controller will then poorly synchronized with your project, and in our case, we found that our exe just wouldn't (except if you are disconnected the 1804 that had the wrong settings).  We also found that you can solve this problem by using the ".iak" file that is created by the project, open it in MAX and save/download the parameters to the controller.  I hope this helps!

  • How to send a single code of hexa from 1 byte with sending VISA for every 500 ms?

    Hello

    I would like to send only a 1-byte hex code in LabVIEW to an external device using RS - 232 (300 bps, 8 data bits, no parity bit, no flow control) every 500 ms.

    The TX pin on the computer should stay at the logical level 1 once he finished transmitting the 1 byte of data and wait before transmitting again 500 ms.

    I'm building a test below code:

    The output of "Channel 1" will connect in the sending VISA write buffer. (Please note that the code above does not include the 500 ms delay I mentioned. Just ignore for a moment.)

    This code will work like what I described above? I tried on my project, but I was getting weird things on the device.

    Convert the code hex correctly?

    And how to send it VISA pass in the string? Does include the other 'useless' strings with the hex code that I want to send?

    Any help will be appreciated.

    Thank you.

    Hi eddiechai...

    you will get a string of length 2, so you have 2 bytes. You must use the U8 and the cast function type. (see attached photo). You have to disable the stop character to get what you want.

    Mike

  • How can I find the code for the corrupted by the sfc scan files?

    I'm new to computers and I'm not aware about many of these things, I have a laptop Dell Inspiron 1545 with a Vista Home Premium operating system on a 64-bit platform, I did a sfc scan and it found 8 files corrupted. I have also a code will correct corrupted files, but I don't know where to find the codes for the corrupted files to put in the code for fixing corrupted files. I found the log file for the corrupted files and it's the same as the instructions I had to use the code to fix the corrupted files but there is nothing in the log file that corresponds with the file name needed to repair the corrupted files. Where can I find these files? Thanks for any help.

    Hello

    Not sure what you mean by you have a code to solve those? Create a sfcdetails.txt and that you post a copy
    each section of a message here - they will repeat in order to do not post duplicate sections, as appropriate.

    ------------------------------------------------------------

    Many files that SFC cannot resolve are not important.

    Start - type in the search box-> find CMD in top - click right on - RUN AS ADMIN

    put the command from below (copy and paste) in this box and her and then press ENTER.

    findstr/c: "[SR]" %windir%\logs\cbs\cbs.log > sfcdetails.txt

    who creates the sfcdetails.txt file in the folder that you are in when you run it.

    So if you're in C:\Windows\System32 > then you will need to look in that folder for the file.

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    in Windows Vista
    http://support.Microsoft.com/kb/928228

    This creates sfcdetails.txt in C:\Windows\System32 find and you can post the errors in a message
    here. NOTE: there are probably duplicates so please only post once each section error.

    You can read the newspaper/txt files easier if you right click on Notepad or Wordpad then RUN AS ADMIN - then
    You can navigate to sfcdetails.txt (in C:\Windows\System32) or cbs.log (in C:\Windows\Logs) as needed.
    (You may need to search sfcdetails.txt if it is not created in the default folders.)

    I hope this helps.

  • Maybe you are looking for