is not a duplicate of my question. I checked it and mine is how to use proper Predicate, and THAT is about differences between removeIf &amp; remove.  I'm beginner Java programmer. Yesterday, I tried to follow this tutorial   After I leared how to use Lambda expressions and Predicate, I made my own code to practice. like, sum all numbers if(n % 3 == 0 || n % 5 == 0). here is my code.  public class Euler1Lambda {     long max;     public Euler1Lambda(long max) {         this.max = max;     } public static boolean div3remainder0(int number) {     return number % 3 == 0; }  public static boolean div5remainder0(int number) {     return number % 5 == 0; }  public long sumAll() {     long sum = 0;     for(int i=1; i&lt;max; i++) {         if (div3remainder0(i) ||div5remainder0(i)) {             sum += i;         }     }     return sum; }  public long sumAllLambda(Predicate&lt;Integer&gt; p) {     long total = 0;     for (int i = 1; i&lt; max; i++){         if (p.test(i)) {             total += i;         }     } return total; }  public static void main(String[] args) {     //conv     long startTime = System.currentTimeMillis();     for(int i = 0; i &lt; 10; i++){         new Euler1Lambda(100000000).sumAll();     }     long endTime = System.currentTimeMillis();     long conv = (endTime - startTime);     System.out.println("Total execution time: " + conv);     //lambda     startTime = System.currentTimeMillis();     for(int i = 0; i &lt; 10; i++){         new Euler1Lambda(100000000).sumAllLambda(n -&gt; div3remainder0(n) || div5remainder0(n));     }     endTime = System.currentTimeMillis();     long lambda = (endTime - startTime);     System.out.println("Total execution time: " + lambda);     System.out.println("lambda / conv : " + (float)lambda/conv); } }   In this code, did timing tests. and result is like this.  Total execution time conv: 1761 Total execution time lambda: 3266  lambda / conv : 1.8546281   As you can see, lambda expression with predicate is slower than simple for-loop. I have no idea why does the result like this. What am I doing wrong? or just predicate is too slow way to use?
How do you write (and run) a correct micro-benchmark in Java?  I'm looking for some code samples and comments illustrating various things to think about.  Example: Should the benchmark measure time/iteration or iterations/time, and why?  Related:
How do I sort a list of dictionaries by a value of the dictionary? Embedding a link (or other html) in a JSF message I'm trying to write a program in C (on Linux) that loops until the user presses a key, but shouldn't require a keypress to continue each loop.  Is there a simple way to do this? I figure I could possibly do it with select() but that seems like a lot of work.  Alternatively, is there a way to catch a ctrl-c keypress to do cleanup before the program closes instead of non-blocking io? Badge "multiplier" a little bit misaligned on the profile page Well, you can see it for yourself. The badge multiplier is a bit misaligned. Can you fix this please? (I know it's kinda a minor issue but it's bugging me and it's somehow off)    If it helps, I'm using Chrome version 44.0.2403.125 m. (Also repro'ed on FireFox 39.0 and )    For no good reason, that's a screenie from 's profile page. String.split() *not* on regular expression? JavaScript adding decimal numbers issue Circuit tester trips new GFCI I replaced a non-protected receptacle with a GFCI type and now my circuit tester trips the GFCI as soon as it is plugged in.  The receptacle tested fine before replacement, ground, neutral, hot, etc.  I've double checked the hot/neutral/ground connections.  I've also tried it with the downstream load disconnected.   The GFCI trips the moment I plug in my circuit tester (before pushing the test button).  Otherwise things check out OK.  I can plug in a power tool without it tripping.  Also, the integrated test/reset button work correctly.   I've read that the integrated test button is the only one that truly matters. Is this correct or should I be concerned? I'm sure a home inspector will red flag this if their tester has the same result.  Update  My tester is by "Commercial Electric".  The tester is one of the palm sized three prong type with three leds to indicate the condition of the circuit and a button on top to test GFCI. It's new from the local box store. Dollar Sign corrupts question In  my question () contains a "$" in a quoted section of the question.  Originally I had a second "$" in a second quoted  section of the same question.    However when I did this the second $ seemed to trigger a style that made the text italic and lost spacing between words.  I took out the second "$" and instead emphasized it with the word "dollars" which solved the immediate problem.  However, in the listing of the question, (not the question itself) the same thing happens after the first "$".  The summary shows the text without spaces between words and in italic.  Seems like a bug.  Below is a verbatim copy/paste of the original issue (two dollar signs):    I was able to find a small ESC for about $12 off of ebay.  If you were designing a robot, would you see that and think?       $12 bucks for an ESC that connects to simple pulse-wave interface -   sign me up!   Or would you think:     $12 just to control a motor? I could throw together an H-bridge for   $0.50 and be done with it.   My robot in particular actually has two motors and therefor $24 to control the two of them.  But the interface is really easy (plus has the added advantage of being R/C vs computer controlled with a simple change of connectors.  Which way would you go? My current prompt is colorized and edited as so -  #!/bin/bash  # GIT Prompt help if tput setaf 1 &amp;&gt; /dev/null; then     tput sgr0; # reset colors     bold=$(tput bold);     reset=$(tput sgr0);     txtund=$(tput sgr 0 1);     black=$(tput setaf 0);     blue=$(tput setaf 33);     cyan=$(tput setaf 37);     green=$(tput setaf 64);     orange=$(tput setaf 166);     purple=$(tput setaf 125);     red=$(tput setaf 124);     violet=$(tput setaf 61);     white=$(tput setaf 15);     yellow=$(tput setaf 136); else     bold='';     reset="\e[0m";     black="\e[1;30m";     blue="\e[1;34m";     cyan="\e[1;36m";     green="\e[1;32m";     orange="\e[1;33m";     purple="\e[1;35m";     red="\e[1;31m";     violet="\e[1;35m";     white="\e[1;37m";     yellow="\e[1;33m"; fi; ORIG=$PS1 HOST=$HOSTNAME PS1="\[${txtund}${green}\]${HOST}\[\[${reset}\]"; PS1+="\$(prompt_git \"\[${white}\] on \[${violet}\]\")"; PS1+="\[${reset}\]"; PS1+="\[ at - ${orange}\W\]"; PS1+="\[${reset}\]"; PS1+="\[ - \u \]"; PS1+="\n\$ ";   I know that the line  PS1+="[ - \u ]"; will show me my current user. However, I want that section to be red if it is root. All other users should be the default color of gray. Is there a way to change the color in that section based off of current user or should I just declare a variable and use an IF statement to insert that section or a modified section with red as a color?  My expected output is gray named user for all normal users. Root should be red. This is BASH. I know some nice ways to prove that $\zeta(2) = \sum_{n=1}^{\infty} \frac{1}{n^2} = \pi^2/6$.  For example, see  or the answers to the question "?"  Are there any nice ways to prove that $$\zeta(4) = \sum_{n=1}^{\infty} \frac{1}{n^4} = \frac{\pi^4}{90}?$$  I already know some proofs that give all values of $\zeta(n)$ for positive even integers $n$ (like #7 on Robin Chapman's list or Qiaochu Yuan's answer in the linked question).  I'm not so much interested in those kinds of proofs as I am those that are specifically for $\zeta(4)$.  I would be particularly interested in a proof that isn't an adaption of one that $\zeta(2) = \pi^2/6$. What Hogwarts classes are taught to two houses at once? I remember from my mumble about nine mumble rereads of the Harry Potter series that the following classes Harry took were taught to more than one house in the same lesson:   Potions with the Slytherins  Herbology with the Hufflepuffs  Care of Magical Creatures with the Slytherins  broomstick riding with at least the Slytherins (maybe other houses, too?)    I don't remember any student from a house that isn't Gryffindor being mentioned in the sections on Transfiguration, Charms, Defense Against Dark Arts, History of Magic, or Divination. That would mean McGonagall had to teach twice as many classes as Snape, if both subjects got the same number of lessons (which I think I recall).   Were any subjects other than Potions, Herbology, and Care of Magical Creatures taught to more than one house in the same lesson? And do we know why some subjects are taught to more students at the same time than others? Finding an old flight number How can I find an old flight number from over three years ago? I am trying to make a claim for a delay of over five hours. They sent us to the wrong destination and lost our luggage. I'm using Ubuntu Maverick and Virtual Box 3+. I have Windows 7 Ultimate. The problem is that it doesn't detect USB drives in Windows 7, but USB peripherals (mouse + keybord) are working.  I followed , but I can't find the user group vboxusers. How can I continue? I would also like to upgrade to the latest version without any risk (without losing my virtual hard disk drive). We've got a Windows 10 installation running in an environment where it can occasionally lose power and restart. However, this sometimes leads to corruption of files.  I've had a look at Windows "To-Go" but this seems to be persistent. And I've also checked out virtualisation, but that would require us to run a non-persistent Windows 10, in another Windows 10 environment.  Is it possible to install Windows 10 as a "non-persistent live CD"? So that a user will have a seemingly fresh Windows 10, but doesn't require to re-install it at each startup? Where to say thanks? Where is the right place to say "thanks" to all those that answered my question? In a comment to my original post, or in a comment to the latest answer or where? Is the inverse of a linear transformation linear as well? A question from the field of Linear Algebra. If I have a linear transformation $T$ that is one-to-one and onto, would that mean that the $T^{-1}$ will also be linear? If so, is there any general proof for it?  Thanks Releasing bound ports on process exit How do I make sure that a socket bound to a port is properly released on process exit such that the port can be reused without bind() failing with EADDRINUSE? I've written a tiny program which just creates a socket, binds it to a fixed port, waits for a connection and then immediately terminates. When I rerun the program, the bind() call fails with EADDRINUSE, but if I wait a few minutes, it succeeds.  Is there a way I can explicitly "unbind" the socket, thereby freeing the port number? Calculating the integral $\int_0^\infty \frac{\cos x}{1+x^2}\, \mathrm{d}x$ without using complex analysis Suppose that we do not know anything about the complex analysis (numbers). In this case, how to calculate the following integral in closed form? $$\int_0^\infty\frac{\cos x}{1+x^2}\,\mathrm{d}x$$ Squid IP Routing Issue I have a squid server installed with 30 additional proxy addresses. Whenever I try to use one of these proxy addresses with a browser, like chrome, my IP shows as the main server IP as opposed to the additional address. For example, say the home IP is 192.0.0.10 and the additional IP I'm trying to use is 192.0.0.13, when going to a &quot;what is my IP&quot; type of site, it shows 192.0.0.10 no matter what additional address I use. Any idea as to why this might happen? Thanks for any help. Maximum area of isosceles triangle with perimeter 6 cm