i am getting Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at  this.commaPos = Name.indexOf("   "); line of my project. The concept is that i have 5 JButtons of ships, and when you click, you place the ship on a Board for a battleship game. Lot of time now i am stuck at this. Any ideas ? Thank you. !  EDIT: I changed the name of String name to String nname. Now i get the same error at the next line. this.commaPos = nname.indexOf(",");   public void stateChanged(ChangeEvent event)   {      JButton currentButton = (JButton)event.getSource();       System.out.println("STATE CHANGED");     String nname = currentButton.getName();     this.commaPos = nname.indexOf(",");     int x = Integer.parseInt(nname.substring(0, commaPos));     int y = Integer.parseInt(nname.substring(commaPos + 1));      checkDeletable(x, y);      if (currentButton.getName().equals(""))       return;     if (this.shipSelected == null) {       return;     }     this.shipSelected.setPos(x, y);      clearOldCoords();     boolean valid = getShipCoords();     paintShip(valid);      if ((currentButton.isFocusOwner()) &amp;&amp; (valid))       placeShip();   }   Here i use the change listener:  {  for (int y = 0; y &lt; 10; y++) {         for (int x = 0; x &lt; 10; x ++) {             this.myBoard[x][y] = new JButton();             this.myBoard[x][y].setMargin(margins);              this.myBoard[x][y].setToolTipText(x + "," + y);             this.myBoard[x][y].setName(null);             this.myBoard[x][y].setIcon(this.sea);             this.myBoard[x][y].addChangeListener(this);             this.myBoard[x][y].addMouseListener(this);              myBoard.add(this.myBoard[x][y]);          }     } }
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?
I'm using  to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value.length == 0 inside of an if statement.  Is there a performance benefit to replacing == with ===?   Any performance improvement would be welcomed as many comparison operators exist.  If no type conversion takes place, would there be a performance gain over ==? When I'm going through a whole bunch of shots to determine which to delete and which to flag, it's fastest for me to just keep both hands on the keyboard.  However, if I want to zoom in to 100% on a picture and then pan to a specific area, it seems I can only get halfway there -- 'Z' to zoom, but then I'm stuck having to pick up the mouse to pan around.  I was excited to find page-up/page-down/home/end can be used, but they seem to exist to provide an exhaustive, linear scrolling of the image, panning top-to-bottom then left-to-right, without unconstrained 2d movement.  Is there some way to toggle the arrow keys so they can pan instead of navigate to the next/prev photo?  Something else?  Or am I out of luck? Show f(x) is a Lipschitz function Let $(X,d)$ be a metric space and $ a \in X $ Show that $f(x) = d(x,a)$ is a Lipschitz function from X to $\Re$ Use this fact to show $S$ is an open subset of $X$: Let $(X,d)$ be a metric space and $a \in X, r &gt; 0.$ Let $S$={$x \in X : d(a,x) &gt; r$}  &gt;Lipschitz Defn:  Let $f$ be a function from $(X,d)$ to $(Y,\rho)$ $f$ is said to be Lipschitz if: $\exists$ K $\geq$ 0 s.t. $\rho( f(x_1) , f(x_2) ) \leq$ Kd($x_1$,$x_2$) $\forall$ $x_1 x_2 \in X$  &gt;Continuity Defn:  Let $(X,d)$ and $(Y,\rho)$ be metric spaces, and $f: X \to Y$ Then $f$ is continuous $iff$ f$^{-1}$($B$) = { $x \in X : f(x) \in B $} is an open subset of $X$, whenever $B$ is an open subset of $Y$  &gt;Triangle Inequality for a Metric:  $d(x,z) \leq d(x,y) + d(y,z)$   My first question is, am I thinking about this correctly? If $f(x)$ is a Lipschitz function, it is uniformly continuous If $f(x)$ is uniformly continuous, it is continuous at every point If $f(x)$ is continuous at every point $\Rightarrow$ the inverse images of open sets are open Hence $S$ is an open subset of $X$.  Secondly, how would you formally construct this? We know $f(x) = d(x,a)$ s.t. $f:X \to \Re$ By definition of Lipschitz we have $\exists  K \geq 0$  s.t. $\rho(f(x_1),f(x_2)) \leq Kd(x_1,x_2) \forall x_1,x_2 \in X$ &amp; since our codomain is $\Re$ $\rho(f(x_1),f(x_2)) = | d(x_1,a) - d(x_2,a) | \leq Kd(x_1,x_2)$ Taking $K=1$ $\ldots$ Help in finishing this off would be appreciated. Thanks. I want to write in hindi in latex  मेरे माता और पिता को समर्पित|  I am using devanagri package and I want to put this in the document using the command {\dn .............}. If somebody can translate the above lines in Devanagari then i can put these in in the blank and get it to work. Also, if there i a tool readily available like google translate, it will be helpful if someone can point out After considering the answers to my previous question (), I've decided to take the 4 or so repositories I have and consolidate them into one. This of course leads to the question, what's the best way to do this?  Is there a way to combine two or more repositories maintaining the version history for both?  Edit: I should also point out that I'm using Assembla.com, which does not provide access to the svnadmin command, AFAIK  Another edit: Does this even matter? If svnadmin works on URLs, then it's no problem then. SEO and URL Shorteners dpkg-divert: error: rename involves overwriting `/usr/lib/xorg/protocol.txt' with different file `/usr/lib/xorg/protocol-precise.txt', not allowed I just installed Ubuntu (12.04.4) and I upgraded to 13.10  I have no idea how to fix this :/  $ sudo apt-get install -f  Reading package lists... Done Building dependency tree        Reading state information... Done The following packages will be REMOVED:   xserver-common-lts-saucy 0 upgraded, 0 newly installed, 1 to remove and 2 not upgraded. 1 not fully installed or removed. After this operation, 1,718 kB disk space will be freed. Do you want to continue [Y/n]? y (Reading database ... 175174 files and directories currently installed.) Removing xserver-common-lts-saucy ... Removing 'diversion of /usr/lib/xorg/protocol.txt to /usr/lib/xorg/protocol-precise.txt by xserver-common-lts-saucy' dpkg-divert: error: rename involves overwriting `/usr/lib/xorg/protocol.txt' with   different file `/usr/lib/xorg/protocol-precise.txt', not allowed dpkg: error processing xserver-common-lts-saucy (--remove):  subprocess installed post-removal script returned error exit status 2 Errors were encountered while processing:  xserver-common-lts-saucy E: Sub-process /usr/bin/dpkg returned an error code (1) How to fix 'android.os.NetworkOnMainThreadException'? Why are the shebang parts of the following elementary scripts not working:  $ cat hello.sh #! /bin/sh echo Hello $ ./hello.sh bash: ./hello.sh: /bin/sh^M: bad interpreter: No such file or directory  $ cat hello.py #! /usr/bin/env python3 print("Hello") $ ./hello.py : No such file or directory   whereas calling the interpreter manually is working:  $ sh hello.sh Hello $ python3 hello.py Hello Rooks on a 8 by 8 checker board. Probability problem Two rooks are placed on an 8 by 8 chessboard such that they're in different squares. What is the probability they can't attack each other? Rooks can attack each other if and only if they're in the same row or column. I know that there are questions like this but they give the general numbers not the probability I am not sure how to start the questions and I have looked at this questions for hours. Any help would be welcome. Elsevier actions following US sanctions on Iran Is it possible to add entries to the bibliography based on keyword using Biblatex/Biber and within the document code? I would like to print a bibliography which includes all entries with a certain keyword (and possibly some additional entries).  I know that I can filter by keyword when I print the bibliography using  \printbibliography[keyword=&lt;keyword&gt;]   but this will only print entries which I have cited. I could, of course, use  \nocite{*}   to add all entries to the bibliography and then print just those I want.  However, this will make my .bbl file huge as my database is enormous.  Another possibility is to use Biber or another tool to prepare a document-specific .bib file containing only those entries with the keyword. However, this would need to be recreated if additional entries with the keyword are added to my main database files.  Here's an MWE to play with, annotated to indicate the way I'd like it to work ;), and the disadvantages of the way it (almost) works.  The issue of excluding explicitly cited entries is less of an issue for me. The thing I'd really like to work around is adding the entire database contents to the .bbl.  \RequirePackage{filecontents} \begin{filecontents}{\jobname.bib} @book{new-stuff,     author          =   {Watt, Brian},     title           =   {Happy Times with Penguins},     publisher       =   {Harvard University Press},     address         =   {Cambridge, MA},     year            =   1995,     pagination      =   {section},     keywords        =   {happy}} @book{den-coll,   author                =   {Till, Jr., Dennis E.},     booktitle           =   {Penguin Land and Further North: Human Influence},     title               =   {Penguin Land and Further North: Human Influence},     publisher           =   {Oxford University Press},     year                =   2008,     address             =   {Oxford and New York},     keywords            =   {penguin, human}} @book{old-stuff,   author                =   {Harvey, Jr., Dennis E.},     booktitle           =   {Penguin Land and Further North: Human Influence},     title               =   {Penguin Land and Further North: Human Influence},     publisher           =   {Someone \&amp; Daughters},     year                =   1567,     address             =   {Oxford},     bookpagination      =   {paragraph},     keywords            =   {penguin}} \end{filecontents} \documentclass{article} \usepackage[defernumbers=true]{biblatex} \bibliography{\jobname} \begin{document}  \cite{old-stuff}  % what I would like to work % \nocite[keyword=happy] % \printbibliography  % what does work - except that \cite{old-stuff} is ignored and, more importantly, den-coll is added to the .bbl \nocite{*} \printbibliography[keyword=happy]  \end{document} Cat 5/6 in same conduit as power: is NM-B required, or is THHN acceptable? no Wi-Fi on Ubuntu 14.04 LTS Asus notebook with MEDIATEK MT7630e I'm new to Ubuntu. I installed it today, but the first thing I encounter is that I can only connect to the Internet through wifi.  Can someone help me?   iwconfig result :  eth0      no wireless extensions.  lo        no wireless extensions.   lspci:  00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM     Controller (rev 09) 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09) 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) 00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) 00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04) 00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1 (rev c4) 00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4) 00:1c.3 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 4 (rev c4) 00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation HM76 Express Chipset LPC Controller (rev 04) 00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04) 00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04) 01:00.0 3D controller: NVIDIA Corporation GF117M [GeForce 610M/710M/820M / GT 620M/625M/630M/720M] (rev a1) 03:00.0 Network controller: MEDIATEK Corp. MT7630e 802.11bgn Wireless Network Adapter 04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5289 (rev 01) 04:00.2 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0a)   lspci -nnk | grep 0280 -A2:  03:00.0 Network controller [0280]: MEDIATEK Corp. MT7630e 802.11bgn Wireless Network Adapter [14c3:7630]     Subsystem: Foxconn International, Inc. Device [105b:e074] 04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device [10ec:5289] (rev 01) Line-breaking widget layout for Android I'm trying to create an activity that presents some data to the user. The data is such that it can be divided into 'words', each being a widget, and sequence of 'words' would form the data ('sentence'?), the ViewGroup widget containing the words. As space required for all 'words' in a 'sentence' would exceed the available horizontal space on the display, I would like to wrap these 'sentences' as you would a normal piece of text.  The following code:  public class WrapTest extends Activity {     /** Called when the activity is first created. */     @Override     public void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         LinearLayout l = new LinearLayout(this);         LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(                 LinearLayout.LayoutParams.FILL_PARENT,                 LinearLayout.LayoutParams.WRAP_CONTENT);         LinearLayout.LayoutParams mlp = new LinearLayout.LayoutParams(                 new ViewGroup.MarginLayoutParams(                         LinearLayout.LayoutParams.WRAP_CONTENT,                         LinearLayout.LayoutParams.WRAP_CONTENT));         mlp.setMargins(0, 0, 2, 0);          for (int i = 0; i &lt; 10; i++) {             TextView t = new TextView(this);             t.setText("Hello");             t.setBackgroundColor(Color.RED);             t.setSingleLine(true);             l.addView(t, mlp);         }          setContentView(l, lp);     } }   yields something like the left picture, but I would want a layout presenting the same widgets like in the right one.        Is there such a layout or combination of layouts and parameters, or do I have to implement my own ViewGroup for this? Are all limits solvable without L'Hôpital Rule or Series Expansion Is it always possible to find the limit of a function without using  or ?  For example,   $$\lim_{x\to0}\frac{\tan x-x}{x^3}$$  $$\lim_{x\to0}\frac{\sin x-x}{x^3}$$  $$\lim_{x\to0}\frac{\ln(1+x)-x}{x^2}$$  $$\lim_{x\to0}\frac{e^x-x-1}{x^2}$$  $$\lim_{x\to0}\frac{\sin^{-1}x-x}{x^3}$$  $$\lim_{x\to0}\frac{\tan^{-1}x-x}{x^3}$$ Is the Dungeon Magazine 4e Adventure List spreadsheet still available? used to go to a spreadsheet with all the 4E adventures published in Dungeon Magazine (and possibly some others, IIRC) during that edition's duration. I remember it listed out each adventure by name, start/end level, adventure path, and maybe even a little summary blurb.  However, the spreadsheet behind that link seems to have disappeared into the digital ether, and I can't find a copy of it in my own google drive (implying I never made a copy of it).  Does anyone happen to have a copy of that spreadsheet that they could share, and/or other resources that would let me sort through the many adventures from 4E Dungeon Magazine? My multimeter is rated to 600V.  How can I readily (and safely) use it to measure higher voltages? Weird large K symbol Three linked question on non-negative definite matrices. 1.a symmetric matrix in $\mathbb{M}_n(\mathbb{R})$ is said to be non-negative definite if $x^Tax≥0$ for all (column) vectors $x\in \mathbb{R}^n$. Which of the following statements are true? (a) If a real symmetric $n\times n$ matrix is non-negative definite, then all of its eigenvalues are non-negative. (b) If a real symmetric $n\times n$ matrix has  all of its eigenvalues are non-negative , then it is non-negative definite. (c) If $ A\in \mathbb{M}_n(\mathbb{R})$, then $AA^T$ is non-negetive definite. 2. only one of the following matrices is non-negetive definite. Find it. (a) $\begin{pmatrix} 5 &amp; -3 \\ -3 &amp; 5 \end{pmatrix}$. (b) $\begin{pmatrix} 1 &amp; -3 \\ -3 &amp; 5 \end{pmatrix}$. (c) $\begin{pmatrix} 1 &amp; 3 \\ 3 &amp; 5 \end{pmatrix}$.      3.let $B$ be the real symmetric non-negative definite $2×2$ matrix such that $B^2=A$ where $A$ where is the non-negetive definite matrix in question $2$.write down the characteristic polynomial of $B$.      My thoughts..  For1.  (a) &amp; (b) are true but not sure about (c). For 2. (a) is the correct option since it has all positive eigen values.they are $2,8$. For 3. Eigen values of $B$ will be $\sqrt{2}$ and $\sqrt{8}$. So the answer is $x^2-3√2x+4=0$.      Can anybody help me to verify the solutions of the above problems.