Lesson3 homework part1

I have a problem in my homework in Lesson 3.

How can I get random source list words?

my code so far:

public List<String> createList(int listSize) {
    Random rand = new Random();
    List<String> wordList = sourceWords.stream().limit(listSize).collect(Collectors.toList());

    return wordList;
  }

Thank you very much for your help!

Try to use the Random provided in the method.  Remember that Random provides a few methods to return a stream of random values.

List of words from the list = rand.ints (listSize, 0, sourceWords.size ())

.mapToObj (i-> sourceWords.get (i)) .collect (Collectors.toList ());

Tags: Java

Similar Questions

  • Lesson 1 homework load: cannot access the java.lang

    I made all facilities and followed all the steps of Lesson1 for the java ME course for Raspberry Pi, but when trying to load the homework examples in the zip file I get the following in Netbeans 8.0.2 error message (and many more mistakes, but I guess that it is the number one key).

    Cannot access the java.lang

    Fatal error: could not find the java.lang package in the classpath or bootclasspath

    ----


    I tried to load the files to work from home with 'file', 'open project' and navigating to the folder with the file build.xml. What I am doing wrong? How these files must be loaded?

    Simple examples with "to go". ' and 'destroy... '. "impression of the lessons worked well, both on the output of the PC console as the Bill pro forma raspberry connected.

    Note, I'm using version 8.1 of ME incorporated, SDK and Plugins currently available on the Oracle website.

    Thanks for your help.

    Willem

    It seems that the SDK was not established as a platform target in the properties of your project by a reason any (for example, older has not installed SDK as a platform project properties).

    Check following:

    1. menu Tools > Java platforms. "Oracle Java (TM) Platform Micro Edition SDK 8.1" should be here as a platform CLDC peresent. If you have not, add it here manually.

    2 menu popup on your project > properties-> platform: you select here as aplatform SDK and the existing mechanism. Note, in the event that your project contains a platform/device this dialog box will be filled with the default (s) value, but you have to press the "OK" button here to apply this default assignment.

  • Methodically, debugging homework 3 part 3 coding

    I am convinced that homework 3, part 2 has been completed and the customer (ECPG - s) ran successfully data display in the putty window.

    If the material and the Raspberry IP configuration is stable. I would like to simplify the troubleshooting steps encoding for reading GPS data, perhaps display the data received in each method and have a map of what it should look like. Are there more references than the "events-data-message-doc' or maybe a part of the video to help with this?

    OR, if a person can offer a suggestion for the not to step in each of the sections of code using "System.out.println", points of rupture or a good system for tracking data through each method (readDataLine, geRawData, getPosition, getVelocity, etc.) is easier to see where the code has problems. To start receiving data, the class AdaFruitGPSUARTSensor must be properly implemented, that close at the end of part 3 and after my coding problem. Perhaps, I placed some features in a fault method. I'm having difficulty to assess that.

    Mike

    I'm not sure what you mean by 'events-data-message-doc' and I don't recall videos specifically on debugging that presenters have used the println command to display data.  However, there are two ways to debug using netbeans.

    First of all, make sure that you have used putty to connect and then the Java ME 8.1 on the IPD has begun and that you have connected your RPi in connection of Device Manager. Nothing will work if you don't do these things first.  You're right, there are two ways to debug.  1. use println.  2. use breakpoints.

    The easiest way is to use println statements.  I use readDataLine as an example.

    Here is my readDataLine method:

    protected String readDataLine() throws IOException {}

    String dataLine = null;

    dataLine = serialBufferedReader.readLine ();

    If (dataLine.startsWith("$")) {}

    return the data row;

    } else {}

    Returns a null value.

    }

    }

    To print the string dataLine, first place your cursor on a line after that the variable data is defined.

    Then type safe (this is a shortcut to the println command).  Don't hit back.  Just type s o u t)

    Then click on the tab key, it develops the shortcut in a full range of valid code.  Your cursor will now be inside a set of quotes.

    Type something like this 'dataLine = "+ data line inside the parens competence.

    Now, your code will look like this:

    dataLine = serialBufferedReader.readLine ();

    System.out.println ("dataLine =" + dataLine);

    If (dataLine.startsWith("$")) {}

    This indicates Java to print the characters ' dataLine = "in the console, then print dataLine.". "  Notice how I put a space before and after the '=' for readability.  You can ignore these spaces if you want.  In fact, you could shorten the whole line and print System.out.println (dataLine); If you don't want to have any explanatory text.

    Now, run the code.  When your code hits this spot dataLine will print on the console.  You can view the console in at least 3 places: 1. The Putty window.  2. in the EmbeddedExternalDevice1 window, click Exit.  3. in the window out into Netbeans.  If you don't see it, click/Window/Output, or press Ctrl and 4 at the same time.  I like the method 3 the best because I can do this in Netbeans without having to open other windows and cluttering up my screen.

    The next method is to use breakpoints.  It's more complicated, but much more powerful.

    To set a breakpoint, see the grey border immediately to the left of your code.  On my Netbeans, this gray area has line in numbers because I said Netbeans to display line numbers (view/show line numbers).  If you have not enabled, the gray area will have nothing in it.  Click in this box to the left of the line you want to add a breakpoint to.  If a red square appears, you have set a breakpoint.

    To activate the breakpoint, you must run your code in debug mode.  If you run the code in the normal Run mode, no breakpoints will activate.  To run code without breakpoints, I click the Green Run button upwards in the toolbar.  Click on project/running, or press F6.  These methods do not enable breakpoints.

    To run in debug mode or click the icon to the immediate right of the Green Run button (it has a picture of a breakpoint and a small green triangle of race), click Debug/Debug project or press Ctrl F5.  Each of these methods should start your project in debug mode.  It runs like it did when you run the project normally, but he's stopping at breakpoints, and it may work a little more slowly because it is now followed for breakpoints.

    Once the breakpoint is reached, the three windows should appear in your code: watches, Variables, breakpoints.  Variables window shows the variables that are in scope at the breakpoint.  If you put a breakpoint on the line after the variable data is defined, you can see the contents of the row of data in the variable window.  Note: If you put a breakpoint on the line of data in row = serialBufferedReader.readLine (); you don't WILL NOT read a value of dataLine because it has not been defined until this statement has been executed.  So move your breakpoint to the next line.

    There is much more to say about debugging.  Here is a link a page describing more information about debugging using NetBeans.

    http://Cobweb.cs.uga.edu/~shoulami/SP2009/cs1301/tutorial/NetBeansDebuggerTutorial/NetBeansDebuggerTutorial.htm

    Answer this, if you have any other questions.

  • The link of the lesson 1 homework does not work.

    The link to Lesson 1 homework does not seem to go anywhere.

    Hi Mikael-

    I'm not having any problem (I have a test account).  Are you sure that your session on the course Page is not exceeded?

    You may need to logout/login and try again - the session expires after 8 hours.

    Tom

  • Week of homework 4 link-&gt; prohibited

    Currently, when I click on the link of homework for the week 4 I get a 403 Forbidden page.

    When I go on the wiki and look at 'all pages', I don't see a page for the duties of the week 4.


    Brent S

    Sorry for the inconvenience, the link has been fixed. Could you please try again?

    Thank you

    Edgar

  • Wire-2nd week homework 1 clarification

    The duties States:

    The second thread starts print messages when the first thread is on an odd interval (ending 5): 12:05, 12:15, etc. This thread will print a message every 30 seconds. This thread illustrates the use of a task interval spaced - for example, a job where you want to collect readings over a period of time to illustrate a rate of change.


    Just so I'm clear, the second thread is triggered to begin printing of messages once and only once, namely when the first thread reaches the first minute '5' end (i.e. 5% min == 0), Yes?  After that, he keeps on printing messages every 30 seconds?  There is no trigger "switch off", OK.


    Thank you


    Brent S


    Brent & Henry - salvation

    The way I wrote homework, it is certainly open to interpretation!

    My solution is consistent with the interpretation of Henry.  Only works the second thread that displays a message every 30 seconds

    5 minutes (10 messages).

    The output looks like this (example):

    Departure time: 14:05:35

    Time: 14:10

    Time: 14:15

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    Time: 14:20

    Time: 14:25

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    To listen...

    Time: 14:30

    But it is not really a good or bad way.  The point of the homework is exploring using wire or timers.

    Tom

  • Q:help with TimerTask in homework #1

    Hello

    so I am trying to create myself a TimerTask (part of homework...) and I'm stuck because I'm not understand what is happening now. I created an imlet that begins the timertask (or at least I think I have). The code that makes it looks like (this part of my IMlet):

    @Override

    public void startApp() {}

    startDate = new Date();

    System.out.println ("HomeWork1IMLet started:" + startDate.toString () .substring (0: 19));

    Timer = new Timer();

    timerTask = new TTask();

    Timer.Schedule (timerTask, 0, 2000);

    }

    My timertask class looks like this (short version):

    import java.util.Date;

    java.util.TimerTask to import;

    SerializableAttribute public class TTask extends TimerTask {}

    @Override

    public void run() {}

    Date startStopDate = new Date();

    System.out.println("1");

    System.out.println ("In TTask wire..." + executionTime (startStopDate));

    System.out.println("2");

    System.out.println ("Mins:" + getRunMinute (startStopDate));

    System.out.println("3");

    If (startSubThread (startStopDate)) {}

    System.out.println ("In TTask (run) wire Tjohoo");

    } else {}

    System.out.println ("In TTask (run) no tjohoo");

    }

    }

    private int executionTime (Date runDate) {}

    return Integer.parseInt (runDate.toString () .substring (0: 19));

    }

    private int getRunMinute (Date runDate) {}

    return Integer.parseInt (runDate.toString () .substring (14, 16));

    }

    Private boolean startSubThread (Date runDate) {}

    int minute = Integer.parseInt (runDate.toString () .substring (15, 16));

    return (minute == 5);

    }

    }

    Now the problem is if I use this class the only thing I get in the console is as follows:

    [INFO] [SECURITY] iso = 1:Application HomeWork1IMlet | atael assigned to the customer "not reliable."

    HomeWork1IMLet started: kills Apr 01 02:31:34

    1

    And I don't understand why I never go further down the code? I want to say that I never see 2 or 3 in the console or on the RPi? No idea what Miss me, I'm probably missing something basic...

    Thank you

    Andy

    Hi Andy -.

    The problem is in this line:

    return Integer.parseInt (runDate.toString () .substring (0: 19));

    You try to parse (as an integer) almost the entire Date String.  The result is a runtime, NumberFormatException exception.

    If you replace the code with a try/catch, you will see the error:

    int result = 0;
    try {}
    result = Integer.parseInt (runDate.toString () .substring (0: 19));
    } catch (NumberFormatException ex) {}
    System.out.println ("NumberFormatException:" + ex);
    }
    return the result;

    Hope this helps,

    Tom

  • PS CS6 copy Css - not here. dumss = (need to do homework

    PS = CS6 my teacher said he had a copy css function (we run cc at school), but I have NooOOO idea why it is NOT appear. I read some places that "you have cloud ps6" but I don't know what that means. I bought the license under 'production premium.' it is ps cs6 + extended. How can I get the copy function css I can do my homework o_o

    ps6 via cc Installer update

    has tried: right click on the layer

    has tried: layer rollout

    Adobe Photoshop Version: 13.0.1 x 64

    Operating system: Windows NT

    Version: 6.2

    I read some places that "you have cloud ps6" but I don't know what that means.

    Time to learn because it is the reason of your dilemma.

    CS6 is available in two flavors: Cloud and non-Cloud.

    Cloud is only available by subscription, and the version number is "13.1.something".

    The perpetually licensed (no-Cloud, a Creative Suite framework) version is what you and the version number is "13.0.something" (yours is 13.0.1).

    "Copy CSS" is available in the Cloud (13.1). If you don't have access to the CSS copy with the version you are using. You must run the version of cloud.

  • Networking to use lighting Homeworks

    The computer is directly connected to the Lutron processor with an Ethernet cable (opposite). If I connect using a windows machine, it works in a moment. But with the merger, I can't. I don't understand. In the software, it gives me the opportunity to "update of the network cards", but nothing is displayed. The static IP address for Lutron processor is 192.168.250... I connected with a true windows computer by using an IP address like 192.168.250.10 for example, but I got access to a network card.

    I bought the merger for that same piece of software. Nothing else. I love my Mac as it is. But now, I am very frustrated. Help, please.

    Fusion 3, Snow Leopard 10.6.2 and lighting Homeworks software using

    ljpell wrote:

    Just to let you know, I finally managed to connect using my Airport Extreme. Somehow, you helped me to understand what I had to do, but it would be nice of you to tell me that you couldn't do anything more for me rather than simply ignoring me and let me wait for a response.

    Who the hell don't you think you are you little ungrateful!  I gave you several good pieces of information in order to try to help you with your situation however is not my fault you're ignorant of the way which properly networked devices together!  Over the past five years, I gave thousands of hours to help people in this area and other free forums by the goodness of my heart, and I can say that you whenever I meet someone who makes a comment, as you just makes me want to give less and less!

  • How iTunes respect my custom artist/Album homework?

    Hello!  I am trying to transfer my iTunes music library (more 11 000 songs) from the hard drive of my old laptop (a Windows machine) to my MacBook Air (MacOS 10.10.5, iTunes 12.3.2) by copying the iTunes Media folder: Music on the old hard drive to the iTunes Media: automatically add to iTunes on my Mac folder.  In the process, I expected to "re-brand" many files to do things like making the composer the artist under which classical compositions are deposited, for example, Bach all in an artist called Bach folder (instead of have it all scattered on in different folders corresponding to the performers) and have all the tracks on the CD to several albums in a single title of the album folder (and not in separate folders for) each drive), etc.  I did already a lot of this work by hand and worked to do things in the Album artist file: unknown unknown, when I accidentally opened iTunes and it began to the add to iTunes process (which I now want to 'Cancel', if possible).  It was my pants up, but then I noticed that all the work I did for the files to "reposition" in the records of the artist and the Album of my choice is not met: in the iTunes Media folder: Music, records that I had deleted have been recreated and files I had put elsewhere were released in the old folder structure , which obviously I don't like, or I wouldn't go to so much trouble to change it.  So is there a way to achieve my goal, i.e., customize the artist and Album of the folder names and content, preferably before all be imported into iTunes, and iTunes will respect and preserve?  Thank you!

    You shouldn't do like that.  Instead, you need to take your entire iTunes folder (and not just your iTunes Media folder) on the Windows PC and put it on the MacBook Air to replace its existing iTunes folder.  iTunes on the new MacBook will look like in iTunes on the old Windows PC, with all songs and data, such as playlists, ratings, play count, date added, etc.  The existing "metadata" will be the same as before, and you can continue to work to better organise your songs in iTunes.

    If you do as you describe, your NEW iTunes library on the MacBook will be more disorganized, and you won't have your playlists (all the songs will be new songs in a new library).  This new iTunes library won't know anything about the old iTunes library.  iTunes doesn't care of the existing folder structure when you import the songs (iTunes considers new songs) to a new iTunes library.  By using the default settings, iTunes keeps the folder iTunes Media organized, based on what you see in the list of iTunes window name song music library (more Track #), Album name and artist name.

    The procedure to transfer your complete iTunes folder is described in this document

    Back up your iTunes library by copying to an external drive - Apple Support

    To sum up, the first step "consolidates" your iTunes media files (from where they are currently stored on your drive), in the designated folder iTunes Media (in your iTunes folder).  All your media files may already be store here.  Second copies of step ("backup") this folder full iTunes (which includes your iTunes library database file very important), on an external drive.  The third step "restores" that backs up the iTunes folder, in your case, for the new MacBook.  With iTunes not running, you replace the existing folder to iTunes of the MacBook with the old Windows PC.  When you run iTunes, it uses this iTunes folder; you see the same iTunes library.

  • Word Pad closed before saving my homework I can get it back?

    I close Word Pad before saving working from home; some way I can get this back?

    Moved from feedback forum.

    Unfortunately, no. WordPad does not AutoSave as it is a very small word processing program. What was on your screen in memory and has been erased from the memory when the program was closed.

    -steve

  • Why my internet explore continue to say, "not responding" every time I make a response on my homework or for only a few minutes?

    This happens especially when I am online with my school work, or school of my son and I answer the questions. This just started happening about a week ago. I deleted cookies, temporary files, etc. and even caching. I have a lot if memory and have cleaned the disk space. I also ran a virus scan. I called technical support for my school, and it doesn't seem to be any way to make it stop.

    Hello

    What antivirus/antispyware/security products do you have on the machine? Be one you ALREADY had on this
    machine, including those you have uninstalled (they leave leftovers behind which can cause strange problems).

    If no joy there's something blocking perhaps.

    Start - all programs - Accessores - system tools - IE with no Addons - does this work better?

    IE - Tools - Internet Options - Advanced - tab click on restore, and then click Reset - apply / OK

    IE - Tools - Internet Options - Security tab - click on reset all default areas - apply / OK

    Close and restart IE or IE with no addons

    not better?

    IE - tools - manage Addons (for sure disable SSV2 if it is there, it is no longer necessary but Java always install
    "(and it causes problems - you never update Java to go back in and turn it off again)." Search for other possible problems.

    Windows Defender - tools - software explore - look for problems with programs that do not look right. Permit
    are usually OK and "unauthorized" are not always bad. If in doubt about a program to ask about it here.

    Could be that a BHO - BHOremover - free - standalone program, needs no installation, download and run - not all
    are bad, but some can cause your question (toolbars are BHO).
    http://securityxploded.com/bhoremover.php

    Startup programs
    http://www.Vistax64.com/tutorials/79612-startup-programs-enable-disable.html

    Also get Malwarebytes - free - use as scanner only.

    http://www.Malwarebytes.org/

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

    Try these to erase corruption and missing/damaged file system repair or replacement.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

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

    Then, run checkdisk - schedule it to run at next boot, then apply OK your way out, then restart.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • My move slider to the other lines and paragraphs and letters when typing e-mails and do their homework.

    As a first step, if you see letters where they aren't suppose to be, I'll put this word in brackets. If you don't see everything, it happens sometimes. I've had this laptop for 18 months. Motherboard has been replaced three times. Cursor and letters move to other lines and paragraphs themselves. This problem is annoying, especially when I do the assignments in class. Is their a fix for this problem, or what?

    Please help, my time is precious.

    Uncle Midgy

    Your laptop has a touchpad?  Chances are good that you are accidentally in touch with her all by tapping and activating the latter and that moves the cursor (and before you notice it, you typed a letter whenever the cursor moves towards).  This happened to me until I bought a separate mouse and disable the touchpad - then the problem has disappeared.

    Some touchpad controls (usually located under the start menu / control panel / mouse have commands to disable the touchpad while typing.)  See if that is the case with yours and if so, activate the function, and it can be useful.  If you do not have the service contact the computer manufacturer to obtain the latest device drivers touchpad and install (and update the drivers for the keyboard while you're there just in case it is the source of the problem, but I think it is the touchpad) - they contain the function as an upgrade.  Go to the Device Manager by going to start / find and type Device Manager and enter and then double-click on the program icon that appears.  Check each device to a red x, yellow! or white?  These identify devices with problems probably (drivers, but also of conflict or something else).  Click on each for more details and troubleshooting tips.  If you need to get drivers (and you do it for your keyboard and touchpad), get the computer dealer or the manufacturer of the device (NOT of Microsoft Updates).  In fact, you must disable automatic updates in Windows Update driver as follows: http://www.addictivetips.com/windows-tips/how-to-disable-automatic-driver-installation-in-windows-vista/. Follow these steps to get the drivers: http://pcsupport.about.com/od/driverssupport/ht/driverdlmfgr.htm.  Once you have the drivers, you can install them via the Manager device as follows: http://www.vistax64.com/tutorials/193584-device-manager-install-driver.html.

    I hope this helps.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • I bought my DESIRE dv6-7220us of Fry "without doing my homework.

    AND, I was not satisfied with the VICTORY-8.  So I installed WIN 7 PRO because I didn't have a touch screen, I did not like APPS and, in order to run some older programs, including AutoCad14 (XP mode).  Everything works OK except the three USB3 ports are inoperative.  I ran a few updates on the HP site, but no fixed my problem.  One works to USB2 port.

    I need drivers USB3 who will work with WIN 7 PRO and my HP ENVY laptop.

    Thank you, Joe [email protected]

    Paul, you're a genius.

    In Device Manager, it shows now:

    Intel USB 3.0 eXtensible Host Controller

    Intel hub USB 3.0

    All three USB3 ports work!

    USB2 works still!

    Such a simple solution when you know what to do.  Thanks again.  Joe

  • I was charged $19.99 each month for Amnesty International and the Ps should come free.  But he said that my free trial is over.  I need to turn in my homework as soon as possible tonight. Can you please install Ps CC for me.

    Can you please install my program Ps I was charge $19.99 each month last September.  Initially, I myself have subscriber but I heard that PS should come free along too.  I need tonight the cc of photoshop.

    > Heard Ps should come free

    I know not where 'heard you' that, but Photoshop does not include Illustrator, you need an additional subscription

    Cloud Plans https://creative.adobe.com/plans

    -Special photography Plan includes Photoshop & Lightroom and Bridge & Mobile Lightroom

    These forums are open 24/7 but Adobe support is not

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

Maybe you are looking for

  • Apple TV and TV remote App

    The application will not work if the apple TV is connected with a network cable and no wifi?

  • Ellitebook HP 2540p: memory upgrade

    Reclassification Elitebook 2540 P memory from 4 GB to 8 GB with (4GBx2) Kingston SODIMM DDR3 1600 MHZ 1.35v CL11 makes it unstable the laptop, it keeps restart continuously. The automatic message comes repairwill apperajust before the newspaper of th

  • R [52] Description of bad ram online?

    Hello I needed a ram upgrade on my ibm thinkpad r52, then I looked towards the top of the form to: http://www-307.IBM.com/PC/support/site.WSS/document.do?lndocid=MIGR-58833#mem Here, it is clearly mentioned that I need DDR ram - so I bought it - was

  • Scan to email on my C5220 HP all-in-one printer

    My HP Photosmart C5280 All-in-one printer.scanner.copier, will scan is no longer e-mail. How can I fix this please?

  • Canon CanoScan 8400F. No driver available.

    No driver available. Is there an updated driver for this device? Moved from feedback Original title: Canon CanoScan 8400F