Using HashMap in Java to make a morse code so i am learning how to use the HashMap object. My question is, if I use the scanner object to ask a user for a String and I save that to a String variable. How can I take that String and "compare" it to my HashMap.   For example if a user inputs "abc".   My HashMap has ("a","abra") ("b","blastoise") ("c","charizard")  I want to print to System.out.println the result -- abra blastoise charizard instead of abc.  I will share my code that i have now but i am stuck with the next step and i hope that i am being clear with my question.       public static void main(String[] args) {      Scanner sc = new Scanner(System.in);     String keyboard = "";     HashMap hm = new HashMap();      hm.put("A","Abra");     hm.put("B", "Blastoise");     hm.put("C", "Charizard");     hm.put("D", "Dewgong");      keyboard = sc.nextLine();   Thank you in advanced :)
What is the easiest/best/most correct way to iterate through the characters of a string in Java? StringTokenizer? Convert the String to a char[] and iterate over that? Something else?
Forcing linebreaks in \url Creating square buffer around point feature using ArcGIS for Desktop? I would like to create a square buffer from a point feature but I do not understand the code that goes into it.   Similar questions have been asked on the forums.esri website but that was over 10 years ago, and it did not work when I tried the code.  How do I create a square buffer from a point feature? Make WCF service be accessible through Internet I've been seeing people getting millions of shiny Pokémon in X &amp; Y without effort. My first shiny on Pokémon X (Corsola) also took only 93 fishing encounters.  I'm wondering: is the chance of finding a shiny in Pokémon X &amp; Y better than it used to be?   If so, what is the chance to find a wild shiny in X &amp; Y? How does it compare to the previous games in the series)? As, the above link shows, other countries have similar murder rates but they are not in the radar of international travelers.  For example, as seen in the list, Puerto Rico has similar statistics. But, personally, I never heard of Puerto Rico to be a dangerous place to travel.  Why is it considered so dangerous to travel in South Africa? Is that due to the incompetent law enforcement agencies? Gradient descent and many other methods are useful for finding local minima in cost functions. They can be efficient when the cost function can be evaluated quickly at each point, whether numerically or analytically.    I have what appears to me to be an unusual situation. Each evaluation of my cost function is expensive. I am attempting to find a set of parameters that minimize a 3D surface against ground truth surfaces. Whenever I change a parameter, I need to run the algorithm against the entire sample cohort to measure its effect.  In order to calculate a gradient, I need to change all 15 parameters independently, meaning I have to regenerate all the surfaces and compare against the sample cohort way too many times per gradient, and definitely way too many times over the course of optimization.  I have developed a method to circumvent this problem and am currently evaluating it, but I am surprised that I have not found much in the literature regarding expensive cost function evaluations.  This makes me wonder if I am making the problem harder than it is and that there might be a better way already available.  So my questions are basically this: Does anyone know of methods for optimizing cost functions, convex or not, when evaluation is slow?  Or, am I doing something silly in the first place by rerunning the algorithm and comparing against the sample cohort so many times? How do I time a method's execution in Java? How do I get a method's execution time?   Is there a Timer utility class for things like timing how long a task takes, etc?     Most of the searches on Google return results for timers that schedule threads and tasks, which is not what I want. Should we improve time to first byte or Page Speed Insights score for SEO? Google posted last summer that "page speed" will impact the search result rankings also on mobile devices. But I think there is a little confusion about the term "page speed".  The test tool which Google offers is called "Page Speed Insights". Many people we are talking with, are thinking that the overall score of this tool for a particular site for example Desktop: 46/100 and Mobile: 45/100 is used for the ranking algorithm.  BUT I found a very interesting article in German language which states that only the TTFB (time to first byte) value is used and this should be optimized not all suggestions which "Page Speed Insights", further called PSI offers. Here is the link to the German article:   In short terms it says that a very large site in this case "The New York Times" has a low overall score of Mobile:41 and Desktop:45. As they are used to sell reader memberships they should  offer a great user experience. So, they should optimize their site. But when I call this site it is amazing fast. The overall PSI score does not reflect this behaviour. But when I believe this article the TTFB for this site is perfect. Also when I call it here from Austria it states 0.881sec.  I really like to know on which value we should focus our work for optimization not to fall in the ranking. Because as many of you already said it is not useful to implement all suggestions from the PSI site for one domain.  So, it would be real  if you could clarify things here or post links to official posts from Google. What I found about this, Google always is talking about "page speed" but what exactly is this? Prove that $(x^2 + x+2)$ ideal is a maximal ideal in $F_3[x]$ ring.  I know the theorem about factor rings and fields     B ideal from A ring is maximal iff A/B factor-ring is a field   How can I use the theorem here? Trying to identify a story about breaking out of a predefined path and no one notices I vaguely remember reading a short story many years ago where something happens and the protagonist gets a bit "out of step" with the rest of the world.  Everyone else keeps acting as if he's still doing what he would have been doing before the event, to the point of carrying on one-sided conversations and the like.  I can't remember much of the plot, but the premise stuck with me.  Edit: To try and explain it more clearly, based on the comment I just wrote, I think everyone else was effectively acting like they were robots with a prerecorded program.  If someone would normally wake up, drink coffee, put on pants, then walk out the door to catch a bus, then if the protagonist broke his coffee cup, stole his pants, and jammed the door, the victim would pour coffee into a broken/nonexistent cup, walk out pantsless, but when he got to the jammed door he might suddenly realize something was up (and thus being "out of step" spreads) or he might continue to go through the motions.  In either case, no one else would notice that the victim was pantsless (or that he didn't make it to work)...  How much of this actually came up in the story, I don't remember. I would like to place a lower limit under two consecutive \sums, somewhere in between. So I have \sum_{j=1}^{\infty}\sum_{k=1}^{\infty} and would like to place j&gt;k in the lower limit between the two sums. I believe the multiple integral operator has this kind of functionality. Why should a CTE start with a semi-colon? How small does a land-mass have to be before you live "on" it, rather than "in" it? I'm sure virtually everyone agrees that people live on the Isle of Wight, but in Ireland.  Apparently the usage depends somewhat on physical size, but that can't be the whole story. How exactly do we decide which form to use? And are there any really glaring 'outliers' that don't fit the normal pattern?  LATER - I must just add that the most uncertain case I've found so far is The Falklands. Most people go for in there, but a substantial minority (about 1 in 3) opt for on. I am trying to write a condition into a SQL WHERE clause that forces the column comparison to a variable to be compared in lowercase. However the addExpression function isn't accomplishing this (since that is putting the expression in the field selection, not the where clause.  Here is what I have tried:  $category = 'mobile wifi'; $query = db_select('taxonomy_term_data', 'ttd')     -&gt;fields('ttd', array('tid')); $query-&gt;innerJoin('taxonomy_vocabulary', 'tv', 'ttd.vid = tv.vid'); $query-&gt;addExpression("LOWER(ttd.name) = $category"); $result = $query-&gt;condition('machine_name', 'images_cat', '=')     -&gt;execute()     -&gt;fetchAssoc();   And this:  $category = 'mobile wifi'; $query = db_select('taxonomy_term_data', 'ttd')     -&gt;fields('ttd', array('tid')); $query-&gt;innerJoin('taxonomy_vocabulary', 'tv', 'ttd.vid = tv.vid'); $result = $query-&gt;condition('machine_name', 'images_cat', '=')     -&gt;condition('LOWER(ttd.name)', $category, '=')     -&gt;execute()     -&gt;fetchAssoc();   The second one becomes invalid and the first one causes the problem I mentioned above. Any thoughts or suggestions?  Thanks, Patrick Let $a_1,a_2,a_3,\ldots$ be reals. Prove that if $\sum_{n=1}^{\infty} a_n^{2}$ converges, then so does $\sum_{n=1}^{\infty} \frac {a_n}{n}$.   For this I have shown the case for when $ a_n^{2} \le\frac {|a_n|}{n}$ $\Rightarrow$ $ |a_n|\le\frac {1}{n}$ $\Rightarrow$ $\frac {|a_n|}{n} \le \frac{1}{n^{2}}$ and we know that $\sum_{n=1}^{\infty} \frac {1}{n^{2}}$ converges and hence $\sum_{n=1}^{\infty}\frac {a_n}{n}$ converges by the comparison test. Now considering $ a_n^{2} \ge\frac {|a_n|}{n}$ $\Rightarrow$ $\frac {|a_n|}{n} \le a_n^{2}$ $\rightarrow$ combining the two cases for any n we have: $\frac {|a_n|}{n}\le\frac{1}{n^{2}}+a_n^{2}$ Hence using the comparion test again we know that $\sum_{n=1}^{\infty} a_n^{2}$ converges and $\sum_{n=1}^{\infty} \frac {1}{n^{2}}$ converges hence the sum converges so we can conclude that $\sum_{n=1}^{\infty} \frac {a_n}{n}$ is absoluetly convergent $\Rightarrow$ convergent.  Not to sure if this is correct, any help would be much appreciated, many thanks. How do I get:  id       Name       Value 1          A          4 1          B          8 2          C          9   to  id          Column 1          A:4, B:8 2          C:9 Why do the big nuts always remain at top? The Brazil-nut Effect Most of the time when I mixed different nuts in a bowl, I observed that the big Brazil nuts were always on top while the small peanuts settled near the base. No matter how you take it, if the big nuts are put at the bottom and then the small nuts are poured, then also after some time the big ones will come to the top. Will not the gravity attract those big nuts more and eventually will they not remain at the base? But it doesn't happen!   I googled it and found the term Brazil-nut Effect but couldn't find any proper explanation. What is the physical explanation for this effect? Bind a key for multiple units to use the same spell grep a file, but show several surrounding lines? I would like to grep for a string, but also show the preceding five lines and the following five lines as well as the matched line. How would I be able to do this? "Typos" are acknowledged as "technical" errors, ones that obviously aren't caused by the writer's poor spelling. Although less frequent than in typing, they can also occur in handwritten texts, as a result of absent-mindedness or just an accidental stroke of the pen.   Since the text wasn't actually typed, it sounds funny to call them "typos". Is there a more fitting word, one that reflects the "accidental" nature of the error?