So I'm given a parameter in which the user chooses which row he wants me to print out, how do I print out the row that the user wants?  This is my 2D array:  Jewel[][] myGrid;   public Jewel[] getRow(int row) {       return null;   }
In Java, arrays don't override toString(), so if you try to print one directly, you get the className + '@' + the hex of the  of the array, as defined by Object.toString():  int[] intArray = new int[] {1, 2, 3, 4, 5}; System.out.println(intArray);     // prints something like '[I@3343c8b3'   But usually, we'd actually want something more like [1, 2, 3, 4, 5]. What's the simplest way of doing that? Here are some example inputs and outputs:  // Array of primitives: int[] intArray = new int[] {1, 2, 3, 4, 5}; //output: [1, 2, 3, 4, 5]  // Array of object references: String[] strArray = new String[] {"John", "Mary", "Bob"}; //output: [John, Mary, Bob]
Testing a UPS by unplugging it from the wall At an Not For Profit/Charity I volunteer for occasionally we were very fortunate to be provided (donated) with a brand new 3Kva APC UPS. This is total overkill for our modest server rack (four mid-range servers and a switch!) but hey, I'll take what I can get!  Pressing the TEST button on the front indicates that yes, the UPS does work. Brilliant. But it only tests it for about 15 seconds.  My question is - will I degrade the UPS by unplugging it from the wall to see how long it will last? My plan is to unplug it, and wait until the battery meter reaches its last LED before plugging it back in, so that I know about how long I will have in the event of a power outage.  Do people do this on a regular basis? I'm guessing no (Lead Acid is very different to Li-Ion batteries)... but what kind of harm would it do if this were to happen (on purpose) every 6 months? Node access based on view mode Finite choice without AC Can anyone explain how we choose one sock from each of finitely many pairs without the axiom of choice?  I mean : To choose one sock from each of infinitely many pairs of socks requires the Axiom of Choice, but for shoes the Axiom is not needed.  The idea is that the two socks in a pair are identical in appearance, and so we must make an arbitrary choice if we wish to choose one of them. For shoes, we can use an explicit algorithm -- e.g., "always choose the left shoe." Why does Russell's statement mention infinitely many pairs? Well, if we only have finitely many pairs of socks, then AC is not needed -- we can choose one member of each pair using the definition of "nonempty," and we can repeat an operation finitely many times using the rules of formal logic (not discussed here). Diagonalizable Operators and characteristic polynomials How do you safely encode a URL using JavaScript such that it can be put into a GET string?  var myUrl = "http://example.com/index.html?param=1&amp;anotherParam=2"; var myOtherUrl = "http://example.com/index.html?url=" + myUrl;   I assume that you need to encode the myUrl variable on that second line? Do I need a UK or Ireland transit visa when flying from the US to a Schengen country? In chrome, most of the time, when i middle click on a link (text or image), it opens a new tab and the current tab does not change. This is the expected behaviour.  However, some websites have links (i'd say 5%) that also switches the current tab to the new one. For example: on this , the name of the players in the main list have the problem.  By looking at the source, i didn't find anything anormal (the link is a standard html tag). But if i disable javascript, i have not the problem. I looked at the source, and didn't find the problematic script... Note also that if i open the tab with right click > open link in new tab, there is no problem.  I'd like to know if you find the reason of the problem and how i can fix it. I am running chrome 10.0.648.204 on windows 7 x64.  EDIT: the website above does not exhibit the behavior anymore, but I sill have the problem sometimes on other sites (which I don't remember) I am creating a chat using Ajax requests and I'm trying to get messages div to scroll to the bottom without much luck. I am wrapping everything in this div: #scroll {     height:400px;     overflow:scroll; }  Is there a way to keep it scrolled to the bottom by default using JS? Is there a way to keep it scrolled to the bottom after an ajax request? When cutting/copying some cells to paste them into another sheet/page, sometimes Excel freezes/locks up and fades out. At the top toolbar it says in brackets "not responding".  Eventually, I must click 'X' to close the program. It offers to wait for the program to respond, but never does – it just does nothing until I finally close it, where it offers to recover files etc.   Is there an issue with memory here? What can I do to stop it locking up? How to uncompress separated tgz files? I am receiving this error message when I'm trying to uncompress a .tgz archive:  $ tar -zxvf OVM_EL5U3_X86_EBIZ12.1.1_DB_VIS_PVM.tgz.1 gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now   As you can see, the file name ends with .tgz.1.  When the file name is .tgz.0 it will be uncompressed with no error by the tar -zxvf command. Can you trade from Pokemon Red on GBA to Pokemon gold on virtual console? I have a Game Boy Advance SP and Pokemon Red GEN 1, and I'm curious if it is possible for me to trade a Pokemon from Red to the Virtual Console release of Pokemon Gold on the 3DS While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of  Name : Value Name2 : Value2   etc.  The peoblem is that the values can sometimes be floats (with different precision), integers, or even in the form 2.20011E+17. What I want to output are pure integers. I don't know a lot of JavaScript, though.  How would I go about writing a method that takes these sometimes-floats and makes them integers? I've just happened to read this  on MO (that of course has been closed) and some of the answers to a similar  on MSE.   I know almost nothing of nonstandard analysis and was asking myself if something like the sentence « $1- 0.999 \dots$ is a nonzero positive infinitesimal» could be easily expressed and proved in nonstandard analysis.  First of all, what is 0.999... ? If we take the usual definition as a series or as a limit of a sequence of rationals, then it will still be a real number and equal to $1$ (I guess by "transfer principle", but please correct me if I'm wrong).  Instead, let's define  $$0.9_N:=\sum_{i=1}^N 9\cdot 10^{-i} $$  where $N\in{}^*\mathbb{N}\setminus\mathbb{N}$ is an infinite nonstandard natural number. This $0.9_N$ is a legitimate element of ${}^*\mathbb{R}$, expressed as $0.$ followed by an infinite number of "$9$" digits.  What can be said about $\epsilon_N:=1-0.9_N$ ? Is there an elementary proof that $\epsilon_N$ is a positive infinitesimal of ${}^*\mathbb{R}$ ? (by "elementary" I mean just order and field axioms and the intuitive facts about infinitesimals, like that for $x$ infinite $1/x$ is infinitesimal etc.; no nonprincipal ultrafilters &amp; C). For which real values of t does the following system of linear equations:  $$ \left\{  \begin{array}{c} tx_1 + x_2 + x_3 = 1 \\  x_1 + tx_2 + x_3 = 1 \\  x_1 + x_2 + tx_3 = 1 \end{array} \right.  $$  Have:  a) a unique solution?  b) infinitely many solutions?  c) no solutions?  I haven't done linear algebra in almost a year, so I'm really rusty and could use some pushes in the right direction. How can I use docker without sudo? On Docker's documentation pages, all example commands are shown without sudo, like this one:  docker ps   On Ubuntu, the binary is called docker.io. It also does not work without sudo:  sudo docker.io ps   How can I configure Docker so that I don't need to prefix every Docker command with sudo? I have a shapefile with contours and their heights.   Is it possible to make a DEM from contours in QGIS without using GRASS?   I found  but the answer is for ArcGIS Desktop. setuid root does not work Objective : Run a program as root (C++ binary). The same as :   And :   ./a.out output:  E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? psurana  //output for "whoami" Look below for the code.   ls -l output:  -rwsrwxr-x 1 root    root    46136 Jun  7 20:13 a.out  The Code :   #include &lt;string&gt; #include &lt;stdlib.h&gt; int main(int argc, char *argv[]){         std::string input = "apt-get install " + std::string(argv[1]);         system(input.c_str());         system("whoami");         return 0; }   Details: : compiled the program and then did chown root:root a.out &amp;&amp; chmod u+s a.out. Please look above for ls -l output.  I still do not get the root privileges and the output for system("whoami") in the code is my own username on the machine.  Reading the two linked questions did not yield me anywhere. :(. both the creator and the owner of the file are root. The setuid bit is set, so it should work. The filesystem is not external either, it is my own machine. How can I make this work? LWJGL Eclipse Resource Deployment I'm still experimenting with some OpenGL in LWJGL, and as I get to know more and more about OpenGL, I start to do more complicated things like multi texturing, shadowmapping and more. Now, right now I'm using the src folder (src/res) for my resources, and use src/resourcename in my code. When I export it, this won't work on another location as the relative path is ofcourse incorrect. What would be the best way of deploying your game with all the resources in one file? Maybe put the files in the jar?  I would like to hear from a few people how they store and deploy their project with resources, thanks! How do you open a command line? How do you access the command line or run option to put the commands into the system? How do I make a bootable Ubuntu USB?