Converting foreach loop to for loop I'm really new to Java, and was wondering if someone could help me convert the following to foreach loops into for loops?  Assuming expression is a collection of items:  for(Type x: expression){    ...    for(Type y: x.expression){      .....     } }
How does the Java 'for each' loop work? Consider:  List&lt;String&gt; someList = new ArrayList&lt;String&gt;(); // add "monkey", "donkey", "skeleton key" to someList     for (String item : someList) {     System.out.println(item); }   What would the equivalent for loop look like without using the for each syntax?
Why are effect size estimates (such as $R^2$) difficult in mixed-effects models? Reading/Writing a MS Word file in PHP Is it possible to read and write Word (2003 and 2007) files in PHP without using a COM object? I know that I can:  $file = fopen('c:\file.doc', 'w+'); fwrite($file, $text); fclose();   but Word will read it as an HTML file not a native .doc file. Opening PDF generated by Python AddIn using Report (*.rlf) file automatcally? As a test I have:   Authored a test.mxd with one layer called Localities in a single data frame called Layers Authored a test.rlf using View | Reports > Create Report of ArcGIS 10.2.2 for Desktop Created a Python AddIn which creates the expected PDF file from the Report (*.rlf).   This is the code which all works to create the PDF report from the Localities features within the current extent:  import arcpy  import pythonaddins  class ReportForExtent(object):     def __init__(self):         self.enabled = True         self.checked = False      def onClick(self):         mxd = arcpy.mapping.MapDocument("CURRENT")         df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]         lyr = arcpy.mapping.ListLayers(mxd,"Localities",df)[0]         arcpy.mapping.ExportReport(lyr,r"C:\temp\test.rlf",r"C:\temp\test.pdf","EXTENT",extent=df.extent)         del mxd   Is there a way to have the Python AddIn not just create the PDF file but also open it in Adobe Acrobat Reader? dpkg: error: dpkg status database is locked by another process I just wondered if somebody could tell me what this means:  E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem. reidsr@ubuntu:~$ sudo dpkg --configure -a dpkg: error: dpkg status database is locked by another process reidsr@ubuntu:~$    How do I run sudo dpkg --configure -a  manually? As the title says. How do I get from  $\frac{n}{\varphi(n)}$ to $\sum\limits_{d \mid n} \frac{\mu^2(d)}{\varphi(d)}$?  I know that $$\frac{n}{\varphi(n)}=\frac{\sum\limits_{d \mid n} \varphi(d)}{\sum\limits_{d \mid n} \mu(d)\frac{n}{d}},$$ and I suspect it is down this road I should go. But I get totally confused by the sums and I have no clue on how to divide them and "combine" them into one again. Any hints or advice would be much appreciated. I had a question about interpreting the graphs generated by plot(lm) in R.  I was wondering if you guys could tell me how to interpret the scale-location and leverage-residual plots?  Any comments would be appreciated.  Assume basic knowledge of statistics, regression and econometrics. Selection Tool doesn't rotate in Illustrator Why my selection tool doesn't rotate object? I selected the object and it doesn't work. How do I fix this? Restoring a backup to an older version of SQL Server Which function (s) is(are) the k-th derivative of itself? As I attempted to solve for a function that is the $k$-th derivative of itself where $k$ is some natural number, and generalise the result, I realised it gets very hard to prove anything. For $k= 1$, apart from trivial corner cases, it's the exponential function with any constant multiplied.  For $k=2$, along with the exponential function and it's reciprocal, it works for their sum along with any mixture by constants multiplied...  For any $k$, I guessed it should be of the form $e^{x w}$ where w is the $k$-th root of unity. And we can add all these $k$ terms for each root with constants multiplied.  While it is easy to verify it's satisfying the condition, it is beyond my scope to prove this is the only family of functions that satisfy it.  I am hoping for some interesting math at work here, and want to know if this is an already established fact. Also, how do I prove anything here? Trying to find a Sci-Fi movie, probably from the 50's or 60's I’m trying to identify a movie I saw when I was very young.  It was a “Saturday Matinee” playing on one of the local stations, and I likely watched it in the late 60’s.  So I expect that the movie is from the 50’s or 60’s.  I watched it in black and white, but it could have been a color movie on a black and white set. I clearly recall a scene where scientists enter a lab and some see something move past them in a blur.  Later in the movie, they come upon themselves in the same lab where they appear to be frozen and not moving.  Then they notice that their “other selves” are moving, just almost inperceptibly slowly.  They are encountering themselves but at a completely different time scale. Unfortunately, I don’t recall much else about the movie, just the idea that they encounter themselves once with the others flashing past, and again seemingly not moving at all.  If this rings any bells with anyone, I’d love some pointers to try to track this movie down. Class vs Struct for data only? Is there any advantage over using a class over a struct in cases such as these?  (note: it will only hold variables, there will never be functions)  class Foo {  private:       struct Pos { int x, y, z }; public:        Pos Position;  };   Versus:  struct Foo {    struct Pos { int x, y, z } Pos; };     Similar questions: If a topology contains all infinite subsets, then it is the discrete topology I am solving question $8$ of exercises in section 1.1. of chapter 1 in "Topology without tears". The question reads as follows.     Let $X$ be an infinite set and $\tau$ be a topology on $X$. If every infinite subset of $X$ is in $\tau$, prove that $\tau$ is the discrete topology   My idea was to show that every singleton set is in the topology and thereby the topology is discrete.  Choose an infinite set $A$ from $X$ such that $A^c$ is also infinite. $A$ and $A^c$ belong to $\tau$ since they are infinite sets. Now consider any $x \in X$. Note that $A \cup \{x\}$ and $A^c \cup \{x\}$ belong to $\tau$ since they are infinite sets. Hence, their intersection which is nothing but $\{x\} \in \tau$ for every $x \in X$.  The problem I have is I don't know how to prove the first sentence in the previous paragraph. These are my line of thoughts to prove them.   If $X$ is a countably infinite set, then I can list the elements are let the odd numbered elements fall into $A$. This guarantees $A$ and $A^c$ are both infinite. If $X$ is uncountable, then I can choose a countably infinite subset and call it $A$.   Are the above arguments rigorous? I am not especially happy with my second argument of choosing a countably infinite subset from an uncountable set since I do not give an explicit procedure of constructing the set $A$.  Also, is there any other simpler way of answering the original question? Prove that if $a+b+c$ divides $abc$, then $a+b+c$ must be composite. how to suppress "chapter" in \chapter (while keeping numbering) "In and of itself" is a phrase I find myself using all the time. But in and of itself, the phrase "in and of itself" has no meaning. That is, the individual words don't seem to contribute to the whole meaning of the phrase. What is the EV scale? I have seen an "EV" (exposure value) scale that's sometimes used to express a camera's exposure settings, or scene brightness. How exactly does this scale work? Extracting text from HTML file using Python Is there an English term for "L'esprit de l'escalier"? What is a good way to transform Cyclic Ordinal attributes? Cleaning ‘staining’ off bottom of MacBook screen A couple months ago, I started to see some very small stain spots on the bottom of my MacBook Pro early 2015 screen. It's very annoying to see while I'm using it. When the screen is turned off, I see it as in the picture below. But when it's turned on, I see it as very small water-ish drops. I tried to clean it using water, screen cleaner, and even alcohol, but it didn't go away.  Also that area doesn't feel as smooth as the unaffected area. So, I think it's on the outside of my screen not inside.  Have you ever seen this before? Any suggestions on how to remove it without the need of replacing the whole screen?