I'm trying to create alertdialogs through a custom dialogframent class  public class Dialogs extends DialogFragment {     @Override     public Dialog onCreateDialog(Bundle saveInstanceState) {         AlertDialog.Builder alert=new AlertDialog.Builder(getActivity());          //additional custom layout here(skipped)          alertDialog=alert.create();         return alert.create();     }      public static Dialogs newInstance(String title, String fields, String buttons) {         Dialogs d = new Dialogs();         Bundle args = new Bundle();         args.putString(TITLE,title);         args.putString(FIELDS, fields);         args.putString(BUTTONS,buttons);         d.setArguments(args);         return d;     }      public List&lt;Button&gt; getButtons() {         return this.buttons;     }      public AlertDialog getDialog(){         return alertDialog;     }   I am calling it in my main activity via  public void AddNewTask() {     Dialogs my_dialog = Dialogs.newInstance("Add New Task",NEW_TASK,NEW_TASK_BUTTON);     my_dialog.getDiag().show(); }   getting  java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.AlertDialog.show()' on a null object reference   I have a hunch it's that the arguments were put after the d was created. So the argumnets didn't pass through? Any help is appreciated  Edit: This is not a question of what is a nullpointer exception. I understand very well what it is. I have solve the problem  for those that possibly have similar issues in the future. I changed the way the dialog was launched inside main activity. It seems like I was missing a fragmenttransaction.   final Dialogs my_dialog=Dialogs.newInstance("Add New Task", NEW_TASK, NEW_TASK_BUTTON);         FragmentTransaction  ft = getFragmentManager().beginTransaction();         my_dialog.show(ft, "dialog");
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 am trying to make a pirate ship and am trying to attach rope to the sails. my rope is made using a path, and soft body physics. I can not find a way to attach my rope to the sail. and I can not use pinned vertices because this is not a cloth modifier. When using \textsc, LaTeX issues warning: Font shape `OT1/cmr/bx/sc' undefined \documentclass{minimal} \usepackage{tikz} \begin{document} \pgfmathparse{random(-5,5)} \pgfmathresult \end{document}   Works, but I have a .0.0 that not supposed to be here. Compare means of group with a mean of a subgroup I tried writing a shell script which can do automatic login into a ssh server using password which is mentioned in the script. I have written the following code:  set timeout 30 /usr/bin/ssh -p 8484 root@172.31.72.103 expect  {    "root@172.31.72.103's password"     {       send "password\r"     } }   This code is not running properly, still it is asking for the password. Can somebody please help me in solving this Do I need internet/3G to use GPS? I have a Samsung Galaxy S2 that has some problems with the GPS: If I use internet my navigation works but when I turn the 3G off, GPS does not work.  Do I need internet/3G to use GPS? Let $(x_n)$ be a sequence of real numbers.  Prove that if there exists $x$ such that every subsequence $(x_{n_k})$ of $(x_n)$ has a convergent (sub-)subsequence $(x_{n_{k_l}})$ to $x$, then the original sequence $(x_n)$ itself converges to $x$ .              Thanks for any help. Direction of $d\mathbf{l}$ A solid sphere has charge $q$ and radius $R$. Find the potential at a point a distance $r$ from the center of the sphere where $r&gt;R$, using infinity as the reference point.  My attempt:  From Gauss' theorem we may deduce that $\displaystyle\mathbf{E}=\frac{1}{4\pi\epsilon_0}\frac{q}{r'^2}\hat{\mathbf{r}}$ where $r'$ is the distance of an arbitrary point from the center of the sphere provided $r'&gt;R$.  $V=-\int_\infty^\mathbf{r}\mathbf{E}\cdot d\mathbf{l}$  My question: What is $d\mathbf{l}$? Since we are traversing in the direction opposite to $\hat{\mathbf{r}}$, I think it should be $-dr'\hat{\mathbf{r}}$. But when I use it to find $V$, I get a sign error. Please help! I'm a web developer, started to become a web designer. However, I think my understanding of colors is not practical yet. There are tools out there that can give you color harmonies, and more stuff, like , but they don't give you the start point. I mean, how should I know that for this web site, I'd better use green and for that website, choose red. How should I know that?  I think color selection is more like an art, instead of being a science, and I'm like "you should become an color artist, in order to become a web designer".  How can I improve my color selection skill? WMS and WFS queries needs SRS and BBOX parameters.  http://example.com/geoserver/wfs?   service=WFS&amp;   version=2.0.0&amp;   request=GetFeature&amp;   typeNames=namespace:featuretype&amp;   srsName=CRS&amp;   bbox=a1,b1,a2,b2&amp;   For example I have GeoServer to publish WFS. My data SRS is EPSG:4326 and my map SRS is EPSG:3857. So I send a WFS query.  http://example.com/geoserver/wfs?   service=WFS&amp;   version=2.0.0&amp;   request=GetFeature&amp;   typeNames=namespace:featuretype&amp;   srsName=EPSG:3857&amp;   bbox=978393.9621,2680799.4560,-430493.3433,3326539.4710&amp;   Does GeoServer or ArcGIS server give an error? Because my data has EPSG:4326 . Or does GeoServer convert these coordinates internally and find data and send me as EPSG:3857 sed - replace string with file contents I have two files: file1 and file2.  file1 has the following contents:  ---   host: "localhost"   port: 3000   reporter_type: "zookeeper"   zk_hosts:      - "localhost:2181"   file2 contains an IP address (1.1.1.1)  What I want to do is replace localhost with 1.1.1.1, so that the end result is:  ---   host: "1.1.1.1"   port: 3000   reporter_type: "zookeeper"   zk_hosts:      - "1.1.1.1:2181"   I have tried:  sed -i -e "/localhost/r file2" -e "/localhost/d" file1 sed '/localhost/r file2' file1 |sed '/localhost/d' sed -e '/localhost/r file2' -e "s///" file1   But I either get the whole line replaced, or the IP going to the line after the one I need to modify. How can one Identify a Magic Item? I had a disagreement with one of my groups recently: They believe that the  spell is the only way to identify a magic item, while I believe a high enough Intelligence (Arcana) check is able to do the same.   What I came here to ask is: What are all the possible ways to identify a magic item? Merge array items into string find the value of limit Find the value of $$ \lim_{n\to\infty} \sum_{k=n+1}^{2n} \frac{1}{k} $$ I think it become a series with each denominator approach infinity. so the value of the limit is 0. am i true ? Why are p-values uniformly distributed under the null hypothesis? When constructing the matrices for the two CNOT based on the target and control qubit, I can use reasoning:  "If $q_0$==$|0\rangle$, everything simply passes through", resulting in an Identity matrix style $\begin{bmatrix}1&amp;0\\0&amp;1\end{bmatrix}$ in the top left. "If $q_0==|1\rangle$, we need to let $q_0$ pass and swap $q_1$, resulting in a Pauli X $\begin{bmatrix}0&amp;1\\1&amp;0\end{bmatrix}$ in the bottom right.  $CNOT \equiv \begin{bmatrix}1&amp;0&amp;0&amp;0\\0&amp;1&amp;0&amp;0\\0&amp;0&amp;0&amp;1\\0&amp;0&amp;1&amp;0\end{bmatrix}$  "If $q_1$==$|0\rangle$, everything simply passes through", results in leaving $|00\rangle$ and $|10\rangle$ unaffected. "If $q_1==|1\rangle$, we need to let $q_1$ pass and swap $q_0$, mapping $|01\rangle$ to $|11\rangle$ and  $|11\rangle$ to $|01\rangle$  $CNOT \equiv \begin{bmatrix}1&amp;0&amp;0&amp;0\\0&amp;0&amp;0&amp;1\\0&amp;0&amp;1&amp;0\\0&amp;1&amp;0&amp;0\end{bmatrix}$  This all seems to check out, but here comes my question: I would like to know if there is a more mathematical way to express this, just as there would be when combining for instance two hadamard gates: $H \otimes H \equiv \frac{1}{\sqrt{2}}\begin{bmatrix}1&amp;1\\1&amp;-1\\ \end{bmatrix} \otimes \frac{1}{\sqrt{2}}\begin{bmatrix}1&amp;1\\1&amp;-1\\ \end{bmatrix} = \frac{1}{2}\begin{bmatrix}1&amp;1&amp;1&amp;1\\1&amp;-1&amp;1&amp;-1\\1&amp;1&amp;-1&amp;-1\\1&amp;-1&amp;-1&amp;1 \end{bmatrix}$  And a bonus question:  How I can, using notation like "CNOT", show which qubit is the control bit and which qubit the target bit? I had a look at Knuth's The Art of Computer Programming, book 1. In chapter 1, section 1.2.2, exercise 25, he presents the following algorithm for calculating logarithm:  given $x\in[1,2)$, do the following:  L1: [Initialize] Set $y\leftarrow0$, $z\leftarrow x/2$, $k\leftarrow1$.  L2: [Test for end] If $x=1$, stop.  L3: [Compare] If $x-z&lt;1$, go to L5.  L4: [Reduce values] Set $x\leftarrow x-z$, $z\leftarrow x/2^k$, $y\leftarrow y+\log_b(2^k/(2^k-1))$, and go to L2.  L5: [Shift] Set $z\leftarrow z/2$, $k\leftarrow k+1$, and go to L2.  (The algorithm needs an auxiliary table which stores $\log_b2$, $\log_b(4/3)$, and so on, to as many values as the precision of the computer.  Then Knuth concludes: this exercise is to explain why the above algorithm will terminate and why it computes an approximation of $y=\log_b x$.  Well, I see that it works, but I am not able to explain why... Is natural projection a natural transformation? Ignore python multiple return value Say I have a Python function that returns multiple values in a tuple:  def func():     return 1, 2   Is there a nice way to ignore one of the results rather than just assigning to a temporary variable? Say if I was only interested in the first value, is there a better way than this:  x, temp = func() Looking for title & author - short story - possibly called "Arms Race" - about rediscovery of manual arithmetic short story - possibly called "Arms Race" - about rediscovery of manual arithmetic.   The hero rediscovers manual calculation - e.g., how to do long division with pencil and paper - in a world where everyone has ben using calculators for aeons. Brought before the president to demonstrate this, the great line in the story is the president, after using his calculator to check the hero's answer, says, "My God -- he's right." A great national project to exploit this advance over the enemy is obviously necessary...