How to get all elements with id = 2?  The below code is giving only the last one i.e. channelMetadataDetail3:  import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors;   public class APICheck {     public static void main(String[] args) {          List&lt;ChannelMetadataDetails&gt; channelMetadataDetails =          new ArrayList&lt;ChannelMetadataDetails&gt;();         ChannelMetadataDetails channelMetadataDetail1 =          new ChannelMetadataDetails();         channelMetadataDetail1.setId("2");         channelMetadataDetail1.setUnitOfMeasureId("3");          ChannelMetadataDetails channelMetadataDetail2 =          new ChannelMetadataDetails();         channelMetadataDetail2.setId("2");         channelMetadataDetail2.setUnitOfMeasureId("3");         channelMetadataDetail2.setMeasureTypeId("5");          ChannelMetadataDetails channelMetadataDetail3 =          new ChannelMetadataDetails();         channelMetadataDetail3.setId("2");          channelMetadataDetails.add(channelMetadataDetail1);         channelMetadataDetails.add(channelMetadataDetail2);         channelMetadataDetails.add(channelMetadataDetail3);          channelMetadataDetails =channelMetadataDetails.         stream().filter(cm -&gt; cm.getId().equals("2")).         filter(cm -&gt; cm.getUnitOfMeasureId().equals(null)).         filter(cm -&gt; cm.getMeasureTypeId().equals(null)).         collect(Collectors.toList());      }     }   NOTE:- If cm.getUnitOfMeasureId() is null then I will get NullPointerException  UPDATE:  In short, I only want those objects whose elements are non-null.  For example using for loop:  for (ChannelMetadataDetails cmEach : channelMetadataDetails) {             if(cmEach.getId() != null &amp;&amp; cmEach.getUnitOfMeasureId() == null &amp;&amp; cmEach.getMeasureTypeId() == null) {                 channelMetadataDetails.stream().filter(cm -&gt; cm.getId().equals("2")).collect(Collectors.toList());             } else if(cmEach.getId() == null &amp;&amp; cmEach.getUnitOfMeasureId() != null &amp;&amp; cmEach.getMeasureTypeId() == null) {                 channelMetadataDetails.stream().filter(cm -&gt; cm.getUnitOfMeasureId().equals("4")).collect(Collectors.toList());             } else if(cmEach.getId() == null &amp;&amp; cmEach.getUnitOfMeasureId() == null &amp;&amp; cmEach.getMeasureTypeId() != null) {                 channelMetadataDetails.stream().filter(cm -&gt; cm.getMeasureTypeId().equals("5")).collect(Collectors.toList());             } else if(cmEach.getId() != null &amp;&amp; cmEach.getUnitOfMeasureId() != null &amp;&amp; cmEach.getMeasureTypeId() == null) {                 channelMetadataDetails.stream().filter(cm -&gt; cm.getId().equals("2") &amp;&amp; cm.getUnitOfMeasureId().equals("4")).collect(Collectors.toList());             } else if(cmEach.getId() != null &amp;&amp; cmEach.getUnitOfMeasureId() == null &amp;&amp; cmEach.getMeasureTypeId() != null) {                 channelMetadataDetails.stream().filter(cm -&gt; cm.getId().equals("2") &amp;&amp; cm.getMeasureTypeId().equals("5")).collect(Collectors.toList());             } else if(cmEach.getId() != null &amp;&amp; cmEach.getUnitOfMeasureId() != null &amp;&amp; cmEach.getMeasureTypeId() != null) {                 channelMetadataDetails.stream().filter(cm -&gt; cm.getId().equals("2") &amp;&amp; cm.getUnitOfMeasureId().equals("4") &amp;&amp; cm.getMeasureTypeId().equals("5")).collect(Collectors.toList());             }         }
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
What can I do if my USB flash drive is write-protected or read-only? When I plug in my USB flash drive, it shows up on my computer as write-protected or read-only. I am unable to transfer data to it, nor can I modify or delete any files already stored on it. I also cannot repartition or reformat the drive using Windows Disk Management, DiskPart, GParted, or other tools. The drive does not have a write-protect switch.  Why did this happen and what can I do about it? Is there a way to remove the write protection?  (Note that this can happen with some memory cards, too, as they often use controllers similar to those used in flash drives. In some cases, the system may report that the drive or card was formatted successfully even though it was never actually formatted; the original data reappears when the device is reinserted.)     This question comes up often and the answers are usually the same. This post is meant to provide a definitive, canonical answer for this problem. Feel free to edit the answer to add additional details. Improper integral $\sin(x)/x $ converges absolutely, conditionaly or diverges?  We have that $$\int_1^{\infty}\frac{\sin x}{x}dx$$ $$u=\frac{1}{x}$$ $$du=-\frac{1}{x^2}dx$$ $$dv=\sin xdx$$ $$v=-\cos x$$ $$\int_1^{\infty}\frac{\sin x}{x}dx=-\cos(1)-\int_1^{\infty}\frac{\cos x}{x^2}dx$$ $$\int_1^{\infty}\frac{\cos x}{x^2}dx&lt;\int_1^{\infty}\frac{1}{x^2}dx$$ So it converges. Now I need to find out if $\int_1^{\infty}|\frac{\sin x}{x}|dx$ converges or diverges. Filtering questions by multiple tags I know you can select a tag and then click on unanswered to view the unanswered questions for that tag.  But is there a way to view questions only for a certain set of tags > 1 tag?  Mainly I'd like the union of tag1 with tag2 with tag3 with tag4. But also the intersection of tags would be nice as well. PGFPlots: Understanding how to draw plots on different layers and arrange them Unable to start XAMPP using sudo in Desktop Entry I am using Ubuntu 18.04. I have installed XAMPP and created a .desktop file to run it.  [Desktop Entry] Type=Application Name=XAMPP Control Panel Version=7.3.0.0 Exec=sudo -i python /opt/lampp/share/xampp-control-panel/xampp-control-panel.py Encoding=UTF-8 Terminal=false Comment=Start and Stop XAMPP Icon=/home/lee/.local/favicon.ico   But, for some reason it won't run. The "Exec" line runs fine on the CL. I have it set to execute. Any ideas? Where is the known_hosts file for OpenSSH for Windows? I would like to know how to understand/analyse the circuit below. And sorry but my level in electronics is not that high and I could only tell that the opposing transistors on the left are meant to cancel any current from the input , yet I don't really understand the B stage which I think the C stage is well related to , and if I wanted to analyse the nodes around the circuit apart from (A,B,C) How can I do it ?  Is it by measuring the current on resistors/nodes?  and note that the output voltage of the circuit in node C is zero this is what it meant to be.I would appreciate any help.  Regards What is the difference between data mining, statistics, machine learning and AI?  Would it be accurate to say that they are 4 fields attempting to solve very similar problems but with different approaches? What exactly do they have in common and where do they differ? If there is some kind of hierarchy between them, what would it be?  Similar questions have been asked previously but I still don't get it: PHP expression <<<EOB UNO Stacking a Draw 4 Card instead of picking up 4 cards? Need clarification on the Draw 4 rule. - Player 1 lays down a Draw 4 Card and says the color is Red. - Player 2 does not have a Red card but has a Draw 4 Card. Can Player 2 lay down his Draw 4 Card and have Player 3 draw 8 cards? Is Autopilot Openstack 16.04 available? Replace Builtin commands with Custom Commands for CMD.exe I'm planning to use USB port for an application(from a device to a PC) but the distance between the device and the PC will be around 15m. The recommended maximum USB cable length is 5m.  How can I buffer the data without loosing any information, safely? Would a USB hub work? Setup SunFire 440 Raid Configuration Unfortunately, despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently. This year my new year's resolution is to not try and learn regex again - So this year to save me from tears I'll give it to Stack Overflow. (Last Christmas remix).  I want to pass in a string in this format {getThis}, and be returned the string getThis. Could anyone be of assistance in helping to stick to my new year's resolution?    Related questions on Stack Overflow: kidle_inject causing very high load Whenever kidle_inject starts running on my system the load shoots up. In general it only gets to a load of around this 5.23, 3.65, 2.54 but a lot of the time it jumps up past the 15 mark on each of them. At that point the system grinds to a halt and I have to power it off.  This only happens when the kidle_inject process starts. How can I disable this process so my machine can work and I can get some work done.  Example top:  top - 12:43:48 up  3:02,  3 users,  load average: 6.57, 5.53, 3.33 Tasks: 256 total,   3 running, 253 sleeping,   0 stopped,   0 zombie %Cpu(s):  5.9 us, 16.6 sy,  0.0 ni, 74.7 id,  0.5 wa,  0.0 hi,  2.3 si,  0.0 st KiB Mem:   8080252 total,  7937856 used,   142396 free,   258904 buffers KiB Swap:        0 total,        0 used,        0 free.  4061336 cached Mem    PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND 13509 root     -51   0       0      0      0 S  54.7  0.0   3:29.47 kidle_inject/1 13511 root     -51   0       0      0      0 S  54.1  0.0   3:30.92 kidle_inject/3 13510 root     -51   0       0      0      0 S  48.8  0.0   3:11.60 kidle_inject/2 13508 root     -51   0       0      0      0 S  47.6  0.0   3:08.47 kidle_inject/0 I'm using an unsigned repo in Ubuntu 16.04 from Debian multimedia:  deb http://www.deb-multimedia.org jessie main   To install deb-multimedia-keyring, I'm running:  apt-get update &amp;&amp; apt-get install deb-multimedia-keyring -y   This gives an error:  W: GPG error: http://www.deb-multimedia.org jessie InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5C808C2B65558117 E: The repository 'http://www.deb-multimedia.org jessie InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details. Uniform Scattering with vector I'm attempting to create a random spread of dots to create a gradient look. I'm getting really close to the effect I want by blending two scatter brushes. The issue I'm having is that the blended brushes creates unwanted lines, and the dots run into each other. I keep adjusting the settings with no luck.  Here's the effect I'm wanting to achieved.    Smooth transition  On Circular path Dots don't converge Scattered at random-ish     Here's how close I'm able to get:   Blended scatters create unwanted lines Dots converge Spacing isn't gradual from edge to center number length limit in SOQL Where condition When I execute SOQL in Developer Console:  Select Id, Amount From Opportunity Where Amount &gt; 10000000000   An parsing error occurs:  Unknown error parsing query   Is there length limit of number on SOQL Where condition? I'm looking for a story that was probably written somewhere from the 1940s to the 1960s. I think I read it in an anthology, possibly in the 1970s.  A group of human explorers landed on a planet with primitive aliens, living in hunter-gatherer villages. They hoped to make a profit from trading our goods for—well, I'm not clear on what they wanted from the aliens.  The native people learned the human language before the explorers could learn theirs. Then the natives suddenly started producing technological innovations far beyond what they originally used. I remember that wooden sailing ships suddenly replaced their canoes. All the natives had to do was hear a story once from the explorers before copying the technology in the story.  Finally, the explorers realized that the natives were much, much smarter than us and that Earth faced a serious problem.  I'm fairly certain that it wasn't a Heinlein story, but I remember that it had some qualities similar to his work.