NullPointerException while checking element of array I have class: public class Board {    private Object[][] fields;     public Board(int x, int y) {        Object[][] fields = new Object[x][y];    }     void IsFree(int x, int y) {        if (fields[x][y] == null)            System.out.println(&quot;Free&quot;);        else System.out.println(&quot;Not free&quot;);  } }  I got NullPointerException when I compare element of array with null. I want to check if this is &quot;empty&quot;.
What is a NullPointerException, and how do I fix it? What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Hide some fields in the NewForm.aspx for a custom list I have 5 columns in the custom list. Out of which only 3 have to displayed in the NewForm.aspx page.  All of the 5 columns have to be displayed on the EditForm.aspx page. While googling, I have come across the following  :  When I implemented the code that was given on this page, I get an error which says that parentNode is not found. Please guide me how can I implement this requirement.  Any other alternatives other than this are also appreciated. Which of these is grammatically correct?       1. a) He has been working under my direct supervision since the last two years           1. b) He has been working under my direct supervision for the last two years            2. a) He has not met her since a very long time        2. b) He has not met her in a very long time    Which of the above are correct? Are all of them correct? My friend says 1.b and 2.b are correct, but I am not sure. Or is this an American English and British English thing? (He mostly goes by American English) Remove "Category:", "Tag:", "Author:" from the_archive_title I have the following code in my theme's archive.php:  &lt;?php the_archive_title( '&lt;h1 class="page-title"&gt;', '&lt;/h1&gt;' ); ?&gt;   This gives me titles like "Category: Russia", "Tag: America", "Author: John".  I would like to remove the "Category:", "Tag:" and "Author:" part and just display the category, tag and author names.  Does anyone know how to accomplish this?  Thank you. double movement in Scrabble Can you resolve a dispute between myself and my girlfriend? She recently won a game with what I think is a double movement (although there's no mention of this in the rule book).  She put one two letters down to make one word, which also scored linked to another letter. But she then added another letter immediately to the left of the finished word, which then extended the second word. I just don't think you can make a second movement like this in scrabble!    My sister placed down W, D and E, the ones that I circled in red. Is she allowed to do that? I told her it was impossible is it?  Can you resolve this for me please? Equivalent of "former" and "latter" for more than 2 items Former and latter are valid only when there are two choices.  If I have a list of more than two items, is there an elegant way to say the first one or the last one? Need hint: Determine whether the series $\sum_{n=1}^{\infty}(\frac{n}{n+1})^{n^2}$ is convergent or divergent. Determine whether the series $\sum_{n=1}^{\infty}(\frac{n}{n+1})^{n^2}$ is convergent or divergent.  I've tried applying all the basic tests to no avail. I need to find out what the "trick" for this particular series is. Redirect the output using `sudo` I have a small question regarding using sudo with output redirect &gt;. To enable IP forwrding, someone can use the command:  echo 1 &gt; /proc/sys/net/ipv4/ip_forward   Executing this command will give permission denied as it requires root privileges. However, executing the same command with sudo gives also permission denied error! It seems that output redirect &gt; does not inherit the permissions of the preceding command echo. Is this right?  As a workaround I do:  echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward   Is this the best way to do it? Am I missing something?  Please, note that this is an example and it applies to all commands that use output redirect. How can I remove duplicate values from a multi-dimensional array in PHP?  Example array:  Array (     [0] =&gt; Array     (         [0] =&gt; abc         [1] =&gt; def     )      [1] =&gt; Array     (         [0] =&gt; ghi         [1] =&gt; jkl     )      [2] =&gt; Array     (         [0] =&gt; mno         [1] =&gt; pql     )      [3] =&gt; Array     (         [0] =&gt; abc         [1] =&gt; def     )      [4] =&gt; Array     (         [0] =&gt; ghi         [1] =&gt; jkl     )      [5] =&gt; Array     (         [0] =&gt; mno         [1] =&gt; pql     )  ) Boy Born on a Tuesday - is it just a language trick? In a bash script what does a dot followed by a space and then a path mean? I came across this example when trying to mount a usb device inside a openvz container and I have never seen the construct in the second line before. Can you explain what it signifies?  #!/bin/bash . /etc/vz/vz.conf Going back twice required to return to search results in the tags view This looks a little bit like a variation on  but specific to the tags view.  Reproduction (app version 1.0.71):   Select any site (say Meta) from the sidebar Switch to the tags view using the top bar Choose a tag, any tag ( is nice)   optionaly refine your search with more terms  Go to any question found, go back   you end on the unfiltered tags view  Go back again   lucky you, your search is here Tile Edge Challenge I've been having a problem with these problems for a week now so I thought I'd post it on MSE. Read the text below. . I've also typed it up:  Annabel made a shape by placing identical square tiles in a frame as shown in the diagram above. The tiles are arranged in columns. Each column touches the base but no columns touch the side or top. There are no empty gaps between columns. The frame can be enlarged as needed.  These are the questions. I've also typed them up.    A. Show that it is possible to arrange $7$ tiles so that the ant walks $8,9,10,11,12,13,14,15$ tile edges.   B. Show 6 ways of arranging 7 tiles so that the ant walks a total of 9 tile edges.  C. Show it is possible to arrange 49 tiles so that the ant walks a total of less than 21 tile edges.  D. Show four arrangements of 137 tiles, each arrangement with a different maximum height, so that the ant walks a total of 34 tile edges.  For question $a$, is there a formula relating the number of tile edges exposed to the number of tiles. These are my answers for $a$    For the above picture, it's the left hand side which has the $a$ answers.  However, I'm having a bit of trouble with $b$. I've already got four answers down but where are the other two. My four current answers are in the right hand side of the last image. Also, I'll also appreciate a formula to show the relationship.  I'm also having trouble with $c$. I found out that you get 21 tile edges exposes when you make a $7*7$ square but the answer is asking for less than 21. Can anyone help me. Also, as in the previous questions, a formula to show the relationships would be great.  And for $d$, I am totally lost. I have no idea where to start, and I certainly can't find out four arrangements. So can anyone help me? And as always, a formula is nice  P.S. Please explain this in an understandable formula, as I'm only a Year 7 with the ability to understand linear algebra and parts of quadratics and trigonometry. Also, sorry about the poor imaging. What does the dot mean On my reelbox (running Ubuntu) I have found a file in /etc/init that contains the following  # frontpanel-pre - check for frontpanel CAPs and adjust time #  description     "check frontpanel caps"  #start on starting mountall #start on tty-device-added DEVNAME=/dev/ttyS0  task  script         (         /sbin/dev_frontpanel.sh         /sbin/reelfpctl -capability         ) &gt; /dev/.frontpanel.caps         initctl emit --no-wait frontpanel-linked end script   I wonder if the dot in /dev/.frontpanel has some special meaning in linux  I thought the output of the commands in the brackets will be written to a file called ".frontpanel.caps" in /dev/ but there is no such file. In /dev/ there is a frontpanel which is a link to /dev/ttyS0  Could it be, that e.g. echo something &gt; /dev/.frontpanel.caps actually sends data (something in this case) to /dev/frontpanel ?  What does .caps do then? So, in my physics textbook it's written that the kinetic energy possessed by a body is equal to the amount of work done by an opposing force to stop the body, now that got me thinking that when a ball hits a wall, the wall which is the opposing force does no work  because there is no displacement, so to say isn't the kinetic energy possessed by the ball zero? Evaluating a sequence of complex numbers: $|z_n - z_m| < \frac1{1+ |n-m|}$ Let $\{z_n\}$ be sequence of complex numbers such that   $$ |z_n - z_m| &lt; \frac{1}{1+ |n-m|} $$ for all $n,m$  Given this information, can we compute $\lim_{n \to \infty} z_n $?  Attempt:  For sure the sequence is bounded since the RHS is always $\leq 1 $. IF $z_m = 0$, then we have   $$ |z_n | &lt; 1 $$ for all $n$. I claim that the limit is $1$. How can I prove this ? How can I create and extract zip archives from the command line? Reflection is quad dependent and looks non realistic Im rendering varous objects with a Sharp glossy effect but the reflections are quad dependent on the object (image below), meaning they behave separately within every quad making it look 8bit-like. Can anyone tell me why this happens?. (Im pretty sure subdividing would fix it but I want to know why I cant have a low poly object reflecting normaly.  The object has 2 modifiers: Subdiv Surface and Solidify. (Perhaps the Subdiv is causing it?). Help me you Blender savys I dont have a powerful CPU to test and test within every render would take me hours and hours.  Image: Find the smallest integer $n$ greater than $1$ such that the last $3$ digits of $n^2$ are the same as the last $3$ digits of $n$. Find the smallest integer $n$ greater than $1$ such that the last $3$ digits of $n^2$ are the same as the last $3$ digits of $n$.  So far I've got $n^2 = 1000k + n$ which means $n^2 ≡ n \mod 1000$. I  don't know how to proceed since 1000 seems to be a bit high. Launcher Icons disappear Some Launcher icons disappear. I locked them but they have disappeared again after boot.  I have Ubuntu 12.04.2 LTS which I have installed today and updated. Terminal prompt not wrapping correctly I have an issue where if I type in very long commands in bash the terminal will not render what I'm typing correctly. I'd expect that if I had a command like the following:  username@someserver ~/somepath $ ssh -i /path/to/private/key myusername@something.someserver.com  The command should render on two lines. Instead it will often wrap around and start writing over the top of my prompt, somewhat like this:  myreallylongusername@something.somelongserver.comh -i /path/to/private/key  If I decide to go back and change some argument there's no telling where the cursor will show up, sometimes in the middle of the prompt, but usually on the line above where I'm typing.   Additional fun happens when when I Up to a previous command. I've tried this in both gnome-terminal and terminator and on i3 and Cinnamon. Someone suggested it was my prompt, so here that is:  \[\033[01;32m\]\u:\[\033[01;34m\] \W\033[01;34m \$\[\033[00m\]  Ctrll, reset, and clear all do what they say, but when I type the command back in or Up the same things happens.  I checked and checkwinsize is enabled in bash. This happens on 80x24 and other window sizes.  Is this just something I learn to live with? Is there some piece of magic which I should know? I've settled for just using a really short prompt, but that doesn't fix the issue.