I'm trying to develop an android app android studio 3.2. When app crashes imageView.setImageBitmap(bitmap);  stopped the app. This  is my code to get an image in drawable         public class MainActivity extends AppCompatActivity {         Button button;         ImageView imageView;         TextView textView;      @Override     protected void onCreate(Bundle savedInstanceState) {         this.imageView=(ImageView)findViewById(R.id.image_view);         textView=(TextView)findViewById(R.id.text_view);         button=(Button)findViewById(R.id.button_click);          try {             this.imageView.setImageResource(R.drawable.helloworld);          }catch (Exception e){             Log.d("error_msg", ""+e);             System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+e);          } //         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);     } }   and also i used this      implementation 'com.google.android.gms:play-services-vision:16.2.0'   How to solve this issue?  D/error_msg: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageResource(int)' on a null object reference   This is the error i got when Catch the error
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?
For a 3D scene in the world coordinates, its View Reference Point $\mathrm{VRP}$ is at $(5,-2,1)$, and a viewer is looking towards point $A=(1,1,1)$. Construct a transform matrix which will map world coordinate points to a right-handed $(UVN)$ viewing space, so that $\mathrm{VRP}$ is the origin, the line joining $\mathrm{VRP}$ to $A$ is the positive $N$ axis, and the view-up Vector is $(0,0,1)$.   To my knowledge, the final answer should be a single transform matrix. To calculate the final matrix, I first find the matrix which translates the coordinate system to the to the origin in homogeneous matrix form:  Translation matrix:  $$ T=         \begin{bmatrix}         1 &amp;0 &amp;0 &amp;-5 \\         0 &amp;1 &amp;0&amp; 2 \\         0 &amp;0 &amp;1 &amp;-1 \\         0 &amp;0 &amp;0 &amp;1 \\         \end{bmatrix} $$  Using the unit vectors of the coordinate axes, the resulting rotation matrix is:  $$ R=         \begin{bmatrix}         -0.6 &amp;-0.8 &amp;0 &amp;0 \\         0 &amp;0 &amp;0 &amp;1 \\         -0.8 &amp;0.6 &amp;0 &amp;0 \\         0 &amp;0 &amp;0 &amp;1 \\         \end{bmatrix} $$ Then the final matrix (the final answer for full marks) would be the rotation matrix multiplied by the translation matrix:  $$ M=         \begin{bmatrix}         -0.6 &amp;-0.8 &amp;0 &amp;1.4 \\         0 &amp;0 &amp;0 &amp;1 \\         -0.8 &amp;0.6 &amp;0 &amp;5.2 \\         0 &amp;0 &amp;0 &amp;1 \\         \end{bmatrix} $$ Is my method and final answer correct?    Following the answer to this question, I have calculated the translation matrix:  $$ T= \begin{pmatrix} 1 &amp; 0 &amp; 0 &amp; -5 \\ 0 &amp; 1 &amp; 0 &amp; 2 \\ 0 &amp; 0 &amp; 1 &amp; -1 \\ 0 &amp; 0 &amp; 0 &amp; 1 \\ \end{pmatrix} $$  I have calculated the rotation matrix:  $$ R= \begin{pmatrix} -0.6 &amp; -0.8 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 1 &amp; 0 \\ -0.8 &amp; 0.6 &amp; 0 &amp; 0 \\ 0 &amp; 0 &amp; 0 &amp; 1 \\ \end{pmatrix} $$  But what would the final transformation matrix $M$ be? My lecture slides tell me it would be rotation matrix multiplied by translation matrix, with the last column multiplied by $-1$ except for the $1$. This would equal:  $$ M = R \times T =  \begin{pmatrix} -0.6 &amp; -0.8 &amp; 0 &amp; -1.4 \\ 0 &amp; 0 &amp; 1 &amp; 1 \\ -0.8 &amp; 0.6 &amp; 0 &amp; -5.2 \\ 0 &amp; 0 &amp; 0 &amp; 1 \\ \end{pmatrix} $$  But the answer here just adds them together somehow. Which one is correct? Find the value of $a^2-b^2+c^2$ Where to place 'only' I have recently found an argument against disabling a root user login in Linux at   I assume that, if everybody uses a public key authentication, there's no risk at losing the root password.  Is it always better to disable the root login via ssh? On duplicate questions, I often see different headings for the duplicate question list. These include:     Possible Duplicate:    [duplicate question list]   and      This question already has an answer here:    [duplicate question list]   and more recently,     This question is an exact duplicate of:    [duplicate question list]   What decides which heading is placed before the duplicate question list? how to have a custom zsh auto_cd command Instead of the normal cd I've created my own function  function cd {     builtin cd "$@" &amp;&amp; ls -F }   This works great for when I use commands like cd someDir/subDir but not when I change directories via zsh's auto_cd someDir/subDir.  Is there a way to customize what command gets called for auto_cd? Extracting extension from filename in Python How can PCB trace have 50 ohm impedance regardless of length and signal frequency? Hmm, this seems to be just another question on line impedances.  I understand that when we say "transmission line" effects we talk about things like cross talk, reflections and ringing (I guess that is just about it). These effects are not present at low frequencies where the PCB trace behaves like an "ideal" transmission medium, more like we expect a wire to behave in our early school days.  I also understand that the 50&nbsp;ohm value comes not from the line resistance which is going to be very small and less than 1&nbsp;ohm. This value comes from the ratio of L and C on the line. Changing C by changing the trace height above ground plane or changing L by changing the trace width shall change the impedance of the line.  We all know that the reactance of L and C is dependant on the signal frequency as well. Now my questions:   Why should we not call this as line reactance only rather than line impedance? How can it be just 50&nbsp;ohm? It has to be signal frequency dependent right?  E.g 50&nbsp;ohm at 1&nbsp;MHz  Will the world end if I chose to do a 100&nbsp;ohm or 25&nbsp;ohm trace instead?  I know that while we like to say 50&nbsp;ohm as a magic number, it will be within some range around 50&nbsp;ohm and not 50.0000 ohm exactly.  Is there any time when the actual resistance of a PCB trace may matter? I got my dad a Logitech LS21 system for Christmas. It's a 2.1 system, but it's recognized in Windows 8 as a 2.0 system (it says there is no subwoofer connected).    How would I go about getting the sub recognized?  It plays some sound now, but it's so quiet you can't hear it without putting your ear right next to it. Data   I want operator users on this machine to mount their own cifs shares The sudoers file already contains the /bin/mount -t cifs //*/* /media/* -o username=* command for all operators I want the users to mount a cifs share through a script typing the password only once, not twice. The sudo password and the cifs password are identical.   What I already have  This script works:  #!/bin/bash sudo 'mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER'   ...but it requires the users to type the same password twice!     Once for sudo Once for the mount itself   This would also work:  #!/bin/bash echo -n Password:  read -s szPassword echo $szPassword | sudo -S sh -c 'echo $szPassword | mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER'   ...but this would require me to allow all operator users to be able to sudo sh (major security problem)  Question  How to mount a cifs share in bash¹ without putting sh in the sudoers file nor creating a permanent/temporary file???  Note 1: no python, perl, C, Go, ... please? Note 2: I know I can just remove the password through the sudoers file, but I'm trying to tighten security, not loosen it, without giving up convenience... Shannon confusion and diffusion concept I read the document(not the whole document) from Shannon where he speaks about the concepts of confusion and diffusion. I read in many places(not in the document but around the internet) that confusion is enforced using substitution. Diffusion is enforced using permutation/transposition. Ciphers must use both of them because either confusion or diffusion alone are not enough. I read that a substitution cipher can apply by itself confusion(only). Permutation/Transposition applies by itself diffusion(only). It's precisely the last case that bothers me: Can a permutation/transposition cipher by itself apply diffusion?  Shannon explains diffusion as a property that spreads statistic properties of text all over the text preventing statistic analysis. It's frequently translated to: an alteration to a plaintext symbol affects many cipher text symbols. Assuming permutation of bits or characters, how can diffusion be achieved by simple permutation? I mean, if you permute bits, there will be no other bits affected. But if you consider a symbol a character and you permute bits, a change in a character will affect many other characters. It's a question of what is a symbol.  I also read versions of this diffusion concept where the point was just changing bits order just to avoid pattern analysis of the text. But, where is the avalanche effect in simple permutation?  So, what is the correct definition and the implications of diffusion?  I hope you understand what is troubling me.  Thank you once more My Android phone is completely reset, whats the best way to recover the deleted data? Why does subsurf modifier cause weird deformation at the end of a cylinder? My problem is simple. I think that the strange deformations on the top are there because there are so many vertices in one face. How do I fix this while maintaining nice topology?  Although I triangulated the top polygon, the problem still persists. I'm currently taking Quantum Mechanics in school and I came across a table displaying the following in the given order:   $E_n (\text{energy levels}), g_n (\text{eigen functions})$   $n \ l, [m]$  $E_1, 1$   $1s, [0]$  $E_2, 4$   $2s, [0]$ $2p, [-1,0,1]$  $E_3, 9$   $3s, [0]$ $3p, [-1,0,1]$ $3d, [-2,-1,0,1,2]$    Now, as I understand $n$ defines the size of the orbital, $l$ the shape and $m$ the orientation.  My question is, how does the atoms shell model fit into this if one can have two electrons per orbital? Are $1s$ the same as the orbital $2s$, but just renamed for the sake of higher energy levels? Or do two similarly looking orbits exist for different energy levels? For example two "layers" of spherical electron clouds for an atom with $4$ electrons.  I just can't see how $2$, $8$, $18$ becomes $2$, $8$, $8$ as we were taught in Physics at high school? Am I missing something? UITextField - capture return button event For example, in this text:     Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eu tellus vel nunc pretium lacinia. Proin sed lorem. Cras sed ipsum. Nunc a libero quis risus sollicitudin imperdiet.   I want to match the word after 'ipsum'. Reversing Drop Bars If I need to sit more upright on an old Fuji road bike, can I turn the drop handlebars upright and reversed so that they come up and then point to the rear?  I haven't seen anything on the net from anyone who has done that. Understanding d-separation theory in causal Bayesian networks I am trying to understand the d-Separation logic in Causal Bayesian Networks. I know how the algorithm works, but I don't exactly understand why the "flow of information" works as stated in the algorithm.    For example in the graph above, lets think that we are only given X and no other variable has been observed. Then according to the rules of d-separation, the information flow from X to D:   X influences A, which is $P(A)\neq P(A|X)$. This is OK, since A causes X and if we know about the effect X, this affects our belief about the cause A. Information flows. X influences B,which is $P(B)\neq P(B|X)$. This is OK, since A has been changed by our knowledge about X, the change at A can influence our beliefs about its cause, B, as well. X influences C,which is $P(C)\neq P(C|X)$. This is OK because we know that B is biased by our knowledge about its indirect effect, X, and since B is biased by X, this will influence B's all direct and indirect effects. C is a direct effect of B and it is influenced by our knowledge about X.   Well, up to this point, everything is OK for me since the flow of the information occurs according to intuitive cause-effect relationships. But I don't get the special behavior of so called "V-structures" or "Colliders" in this scheme. According to the d-Separation theory, B and D are the common causes of C in the graph above and it says that if we did not observe C or any of its descendants, the flow information from X is blocked at C. Well, OK, but my question is why?  From the three steps above, started from X, we saw that C is influenced by our knowledge about X and the information flow occurred according to the cause-effect relationship. The d-Separation theory says that we cannot go from C to D since C is not observed. But I think that since we know that C is biased and D is a cause of C, D should be affected as well while the theory says the opposite. I am clearly missing something in my thinking pattern but can't see what it is.  So I need an explanation of why the flow of information blocked at C, if C is not observed. Why did Dumbledore tell Harry there were 6 Horcruxes when he already knew Harry was a horcrux? Harry: "He made seven Horcruxes?"   Dumbledore: "...Not seven Horcruxes: six. The seventh part of his soul, however maimed, resides inside his regenerated body..." (HP6, US Hardback, page 503).    I would think that Dumbledore had already known that there were 6 horcruxes:    the diary  Gaunt's ring  Salazar's locket Helga Hufflepuff's cup Nagini (the whole essence divided thing)   Now those are the five that he was sure of. He knew that when Riddle came to Hogwarts to ask for the DADA position, he was really there so he could hide a horcrux. (But he never got a chance to tell Harry that, right?) Did Dumbledore know of the diadem? Or did he just think Riddle wanted to hide the cup?   Did Dumbledore say there were 6 and not 7 because he didn't know about the diadem but did know about Harry being a horcrux? Or did he say there were 6 to ensure Harry didn't guess he was a horcrux? Sorry if this makes no sense.  I know that in the end there were 7 horcruxes and an 8th part of Voldemort's soul right? Pytest is in PATH but not found