I'm pretty new to Java and in an effort to learn more I'm trying to make a game whereby you're given a random lyric from a song, and then the song title and artist.   This would be pretty easy, however I wanted the lyric to be random, and then print the artist and song title using a seperate method. My problem is that I'm not sure how to go from printing one random string to printing a specific answer.  I currently have the lyrics and the answers in a hashmap with the lyrics as keys and answers as values, and can print random keys by turning them into an arraylist using this method  public void randomLyrics()     {         ArrayList&lt;String&gt; lyricKey = new ArrayList&lt;String&gt;(lyrics.keySet());         if(lyrics.size() &gt; 0) {             Random rand = new Random();             int index = rand.nextInt(lyrics.size());             System.out.println(lyricKey.get(rand.nextInt(lyrics.size())));         }     }   however I'm pretty sure that this isn't the right way to go about it, and am not sure how I would go about printing the answers seperately.   Any help would be much appreciated.  Also just to clarify, I want to call a method (randomLyrics) which will display a random lyric such as "that's me in the corner, that's me in the spotlight" and then call a seperate method (answer) which would then print "Losing My Religion - R.E.M."   Many thanks
If I have an object implementing the Map interface in Java and I wish to iterate over every pair contained within it,  what is the most efficient way of going through the map?  Will the ordering of elements depend on the specific map implementation that I have for the interface?
How do you detect where two line segments intersect? Why does Property Set throw StackOverflow exception? I know java and would normally put in getter/setter methods. I am interested in doing it in C# with the following code, but it throws a StackOverflow exception. What am I doing wrong?  Calling Code  c.firstName = "a";   Property Code    public String firstName; {     get     {         return firstName;     }     set     {         firstName = value;     } } I was using the amspset document class for generating exam practice problems. I had wanted to add some referencing to the problems so I started a new counter like this (adapted from some Tex Exchange post)  \newcounter{P} \newcommand{\plb}[1]{\refstepcounter{P}\label{#1} \textbf{P-\ref{#1}.}}  \begin{problem} \plb{p1} A parallel-wire transmission line is constructed of \#6 AWG copper wire (diameter $d=0.162$ in., conductivity $\sigma_c=5.8\times 10^7$ S/m) with a 12-inch separation in air. Assuming no leakage between the two wires, find $R'$, $L'$, $G'$, and $C'$. Assume a working frequency of 1 MHz. \end{problem}  \begin{solution} Using Table.~\ref{tab:tlparam} and Fig.~\ref{fig:tlempl},  \[ Rs = \sqrt{\pi f \mu_c/\sigma_c} = 2.61\times10^{-4}~ \Omega\] \[ R' = \frac{2R_s}{\pi d} = 4.04\times10^{-2} ~\Omega\text{/m} \] \[ L' = \frac{\mu_0}{\pi} \ln{\frac{2D}{d}}=2.0~\mu \text{H/m} \] \[ C' = \frac{\pi \epsilon}{\displaystyle\ln{\frac{2D}{d}}}=5.56 ~\text{pF/m} \] $G'=0$ because the problem states that there is no leakage between the two wires. \end{solution}  \begin{figure}[ht] \begin{centering}     \includegraphics{fig24}     \caption{(Fig.2-4 from FAE) A few examples of transmission lines.} \end{centering} \label{fig:tlempl} \end{figure}  \begin{table}[ht] \caption{(Table 2-1 from FAE)Transmission-line parameters $R'$, $L'$, $G'$, and $C'$ for three types of lines.}     \begin{tabular}{c}         \hspace{3cm}\includegraphics{tb21}     \end{tabular} \label{tab:tlparam} \end{table} ... and more   Now all the figure references stop working, I get "Fig. " instead of "Fig. 1". The table references are alright though. Any idea what the problem could be? How to use hook_node_presave to change field's value Is it acceptable to say "We'll get back to you as quick as we can"? Is "quick" a flat adverb in this case? Calculating the total number of surjective functions It is quite easy to calculate the total number of functions from a set $X$ with $m$ elements to a set $Y$ with $n$ elements ($n^{m}$), and also the total number of injective functions ($n^{\underline{m}}$, denoting the falling factorial). But I am thinking about how to calculate the total number of surjective functions $f\colon X \twoheadrightarrow Y $.  The way I thought of doing this is as follows: firstly, since all $n$ elements of the codomain $Y$ need to be mapped to, you choose any $n$ elements from the $m$ elements of the set $X$ to be mapped one-to-one with the $n$ elements of $Y$. This results in $n!$ possible pairings. But the number of ways of choosing $n$ elements from $m$ elements is $\frac{m!}{(m-n)!\,n!}$, so the total number of ways of matching $n$ elements in $X$ to be one-to-one with the $n$ elements of $Y$ is $\frac{m!}{(m-n)!\,n!} \times n! = \frac{m!}{(m-n)!}$.  Now we have 'covered' the codomain $Y$ with $n$ elements from $X$, the remaining unpaired $m-n$ elements from $X$ can be mapped to any of the elements of $Y$, so there are $n^{m-n}$ ways of doing this. Therefore I think that the total number of surjective functions should be $\frac{m!}{(m-n)!} \, n^{m-n}$.  Is this anything like correct or have I made a major mistake here? Laravel - Populating Select List with Derived Values Normal subgroup of a normal subgroup Let $F,G,H$ be groups such that $F\trianglelefteq G \trianglelefteq H$.  I am asked whether we necessarily have $F\trianglelefteq H$. I think the answer is no but I cannot find any counterexample with usual groups. Is there a simple case where this property is not true? How can you construct the bijection between real numbers and functions over naturals? Improving how suggested edits are displayed in your activity history Issue 1: I find it a bit irritating that when I click the Improve button and further edit it, even if I mark it as helpful, only Community takes the credit for the approval. I know the topic itself will contain the link to the suggested edit, but my activity history only says that I made an edit, and not approved a suggested edit. The same holds true for marking one as unhelpful. The activity history should say I rejected an edit, and then made an additional edit. I know it's not often, but sometimes I do try to go back to a suggested edit I've rejected, but when I improved and rejected, it's not traceable for me as it doesn't show in my history or in the question's revision history. So if I don't remember what user suggested it, it's lost to me.  This issue also plagues the  which are awarded for approving and rejecting suggested edits, which essentially you have done, you're just not receiving credit for it. I suggest that when I mark an edit as helpful or not helpful, both me and Community be listed as the approvers or rejecters, unless another user is already listed in the appropriate place.  Update: Here is  of the confusion this causes.  Update 2: Also, when improving a post and marking it as "not helpful", it would be nice to be able to  along with it.    Issue 2: Expanding off the idea that users need more notice for suggested edits that get rejected, the activity history page is much too useless when it comes to listing the suggested edits a user has made. Literally all it does is list them. A user still has to click through to each one in order to find out if it was approved or rejected, or even if it's still pending. Take, for example, this screen shot of the suggested edit history:    Is it really necessary to say I suggested a suggested edit? Really? Of course I suggested it, it's a suggested edit. This isn't !  A good way to fix this would be to change the second "suggested" word into one of: pending, approved, or rejected. This would be a quick way to tell which edits have been approved or rejected and which ones are still pending. Users would be able to target out rejected edits and review them for the reasons. Something like this: So I was in my New Leaf house and I accidentally put on a pair of pants instead of displaying them. Then I went and clicked on myself and I have no option to take off my pants. Ever. I swapped them with another pair for the display, but I can't get those off either. And the weird bit is when I put on the pants nothing was swapped back to my inventory.  How do I take off my pants? How to evaluate  $$\det\begin{bmatrix}1+x_1y_1&amp;\cdots &amp; 1+x_1y_n\\ \vdots &amp; \ddots &amp; \vdots \\ 1+x_ny_1 &amp; \cdots &amp; 1+x_ny_n\end{bmatrix}$$?  I tried factorisation but I have no idea. I could not factor anything out... I need a hint to kick off.   Edit: A conjecture due to multilinearity: if we let $v_j=(x_1y_j,\cdots,x_ny_j)^T$, then my guess would be $$\det\begin{bmatrix}1+x_1y_1&amp;\cdots &amp; 1+x_1y_n\\ \vdots &amp; \ddots &amp; \vdots \\ 1+x_ny_1 &amp; \cdots &amp; 1+x_ny_n\end{bmatrix}=\det(1,v_2,\cdots,v_n)+\det(v_1,1,\cdots,v_n)+\cdots+\det(v_1,v_2,\cdots,1)=\color{red}{0}$$ where $1$ denote $(1,\cdots,1)^T\in \Bbb K^n$,$\Bbb K$ the underlying number field. I have two partitions, one of them has a file system and the other is unallocated.  How to merge two partitions? I need to get execution time in milliseconds.  I originally asked this question back in 2008. The accepted answer then was to use  However, we can all agree now  that using the standard  API is more appropriate. I am therefore changing the accepted answer to this one. Do thermostat-controlled, auto-adjust HVAC vents exist? The residential forced-air HVAC systems I have seen are controlled by a single thermostat in one room.  One has to manually adjust the vents in order to adjust the temperature in other rooms.  Is there such a think as thermostat-controlled, automatically-adjustable vents so that one can have multiple heating/cooling zones without having multiple furnaces and air-conditioners? How to see if certain representation of $SU(2)$ is symmetric/antisymmetric/mixed? I am looking at the tensor product of $n$ spin halfs (fundamental of $SU(2)$): \begin{equation} \left(\frac{1}{2}\right)^n = \frac{1}{2} \times \frac{1}{2} \times ... \times \frac{1}{2} = \frac{n}{2} + ... \end{equation} For example, for $n = 3$ \begin{equation} \frac{1}{2} \times \frac{1}{2} \times \frac{1}{2} = \frac{1}{2} \times \left(1 + 0\right) = \left(\frac{3}{2}\right)_1 + \left(\frac{1}{2}\right)_1 + \left( \frac{1}{2} \right)_0 \end{equation} where lower indexes on the right hand side specify from which tensor product representation came from. My question is how do I read off if a certain term on the right is a symmetric, antisymmetric or a mixed symmetry representation of $SU(2)$? I came up with two ways of approaching the problem.  First is Young Tableaux. As far as I understand rows of Young Tableaux correspond to symmetric indexes while columns to antisymmetric ones. So, for example, a diagram with just one row (like one that corresponds to the highest spin $\frac{3}{2}$ from the example - three boxes in a row) describes a totally symmetric representation. A diagram that has one column (maximum 2 boxes since we are dealing with $SU(2)$) describes totally antisymmetric representation. Everything that has both rows and columns is a mixed symmetry representation. Following this logic it looks like only the highest representation in the product can be totally symmetric, singlet is antisymmetric and everything in between has mixed symmetry. So, for the example \begin{equation} \left(\frac{3}{2}\right)_1: \text{symmetric rep}\\ \left(\frac{1}{2}\right)_{0,1}: \text{mixed symmetry reps}\\ \end{equation} Is this is a correct logic?  Another way to think about this is the following. Let's build representation the way we do in QM starting from the highest one, when all the spins are up. Then all components of the highest multiplet can be generated by applying lowering operators to the highest state. So, all the relative signs in the expressions are &quot;+&quot; and thus the highest representation is always symmetric as 1. also suggests. Then all the other representations must be constructed by writing down expressions orthogonal to components of the highest multiplet, so they will necessary get some &quot;-&quot; signs and as a result must be either antisymmetric or have mixed symmetry, but can not be totally symmetric.   Is this correct logic? Is it true that only the highest representation in the product can be symmetric and all the others have mixed symmetry or antisymmetric? How do I programmatically force an onchange event on an input? How do I programmatically force an onchange event on an input?  I've tried something like this:  var code = ele.getAttribute('onchange'); eval(code);   But my end goal is to fire any listener functions, and that doesn't seem to work.  Neither does just updating the 'value' attribute. In  video, he uses a command block to give him jump boost while he is wearing his Boots of Leaping.  I am trying to imitate this for a multiplayer map I am making. Wearing golden boots called "Stealth Boots" is supposed to give that player invisibility. I am using this command:  /effect @a[Inventory:[{Slot:100b,tag:{display:{Name:"Stealth Boots"}}}]] 14 30000 200  I do know that in the video he is using a /testfor command, but since I'm making a multiplayer map in order to use this technique I'd have to define a scoreboard variable for each player - and even then, the players would be finite. Thus, I want to be able to use the command DIRECTLY.  When I use that command, it either says "That player cannot be found" or "The entity UUID provided is in an invalid format" - the former of which I'm familiar with; the later I've barely ever seen before.  So, my method doesn't seem to work - how do I fix it? I am playing with LINQ to learn about it, but I can't figure out how to use Distinct when I do not have a simple list (a simple list of integers is pretty easy to do, this is not the question). What I if want to use  on a list of an Object on one or more properties of the object?  Example: If an object is Person, with Property Id. How can I get all Person and use Distinct on them with the property Id of the object?  Person1: Id=1, Name="Test1" Person2: Id=1, Name="Test1" Person3: Id=2, Name="Test2"   How can I get just Person1 and Person3? Is that possible?  If it's not possible with LINQ, what would be the best way to have a list of Person depending on some of its properties in .NET 3.5? What would happen if two wizards made each other a Horcrux? Would they be invincible? How would you kill one of them?