I'm trying to add a song from one class to a second Album class. But i'm getting "Exception in thread "main" java.lang.NullPointerException" error. I'm new to java and any help is appreciated.  public class Album { // class behaviours private String albumName; private Song[] songs; private int totalAlbumLength; private int numSongs;  // constructor public Album(String albumName) {     setAlbumName(albumName); }   // special setters: adding new song public void addSong(Song newSong) {     this.songs[this.numSongs] = newSong;     this.numSongs++; }  public void addSong(String songName, String artistName, int minutes, int seconds) {     Song newSong = new Song(songName, artistName, minutes, seconds);     addSong(newSong);  }   Song class  public class Song { // class behaviours private String songName = ""; private String artistName = ""; private int songLength = 0;  // constructors public Song(String songName, String artistName, int minutes, int seconds) {     setSongName(songName);     setAtristName(artistName);     setSongLength(minutes, seconds); }  public Song(String songName, String artistName, int seconds) {     setSongName(songName);     setAtristName(artistName);     setSongLength(seconds); }
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?
How is the Gmail password stored in Android - and where? I have looked around and found no information on how Android manages to store passwords on the device. Especially Gmail passwords. I'm looking to learn how Android encrypts and stores passwords ? What key does it use and where is this key stored, and what encryption algorithm it uses. How can one show that a möbius transformation maps the unit circle to some axis? Suppose I have the möbius transformation f(z) = $\frac{1+z}{1-z}$ and I want to show that it will map the unit circle (excluding the point 1) to the imaginary axis.  Would it help to express my unit circle in polar form?     Here's what I did: f(e$^{i\theta}$) = $\frac{1+e^{i\theta}}{1-e^{i\theta}}$  But I'm not sure where to go from this step. Reduce Classification Probability Threshold I have a question regarding classification in general. Let $f$ be a classifier, which outputs a set of probabilities given some data D. Normally, one would say: well, if $P(c|D) &gt; 0.5$, we will assign a class 1, otherwise 0 (let this be a binary classification).   My question is, what if I find out, that if I classify the class as 1 also when the probabilities are larger than, for instance 0.2, and the classifier performs better. Is it legitimate to then use this new threshold when doing classification?  I would interpret the necessity for lower classification bound in the context of the data emitting a smaller signal; yet still significant for the classification problem.  I realize this is one way to do it. However, if this is not correct thinking of reducing the threshold, what would be some data transformations, which emphasize individual features in a similar manner, so that the threshold can remain at 0.5? Launch app only if not already open No indentation after theorem environment with amsthm I use the amsthm package and dont want lines which start right after the theorem environment to be indented. I consulted the manual of the package and it said to define a new theorem style. I expected the following MWE to accomplish this task.  \documentclass[12pt,a4paper]{scrreprt}  \usepackage{amsthm} \newtheoremstyle{abcd}% name   {}%      Space above, empty = `usual value'   {}%      Space below   {\itshape}% Body font   {}%         Indent amount (empty = no indent, \parindent = para indent)   {\bfseries}% Thm head font   {.}%        Punctuation after thm head   {.5em}% Space after thm head: \newline = linebreak   {}%         Thm head spec \theoremstyle{abcd}  \newtheorem{defn}{Definition} \begin{document} \begin{defn} Some defintion \end{defn} This sentence shouldn't be indented. \end{document}   However, I end up with this   That is what I would expect (obtained using a noindent right after the theorem environment ends) Are the rationals a closed or open set in $\mathbb{R}$? How can I use "." as the delimiter with String.split() in java Is it better to have an ErrorDocument 404 redirect back to the homepage or a standard 404 error page? Someone who does not like excess I am trying to find the correct opposite of a delegate in the context of a person being a representative of someone else that have allowed or chosen them to be their delegate. What would you call that "someone else?" The only word I could find is a delegator (which isn't a real word in English) or assigner, but they are technical words rather than descriptive.    Any other word I could use?    Think of it in a sentence like this:       Here is a list of all the delegates in the company.   But that is the list of their _ _ _ _ _ (what can go here?).   I am trying to avoid fillers such as:  bosses, agents, managers, etc. What's the difference between the atomic and nonatomic attributes? What do atomic and nonatomic mean in property declarations?  @property(nonatomic, retain) UITextField *userName; @property(atomic, retain) UITextField *userName; @property(retain) UITextField *userName;   What is the operational difference between these three? Reputation and inbox notification shows up again after refresh PayPal API Listener Website Payments Standard URI My account has 20 (!) sites associated to it.  I only use it for 3-5 sites.  To reduce clutter, I would like to delete my profiles that I do not use much.  I have went through , but when I enter the profile URL as:  http://russian.stackexchange.com/users/5772/alex   it gives the error message:     oops! this isn't a link to a valid profile   What procedure do I go through to delete my profile only on certain sites? How can I prove that $\mathbb{Q}[x,y]/\langle x^2+y^2-1 \rangle$ is an integral domain?  Also, I need to prove that its field of fractions is isomorphic to the field of rational functions $\mathbb{Q}(t)$?    (The question is taken from ) jquery stop child triggering parent event A word that means stage-fright, but for a person? Suppose you met a famous person, and you were shy and anxious and almost overwhelmed by them.   Is there a word for describing that? Similar to getting stage fright, or "choking", except in this case for a person?     When he said hello to me, I couldn't respond. I (was) __________. What happens if I use RAM of a faster speed than the CPU supports? class C {   T a; public:   C(T a): a(a) {;} };   Is it legal? When should I use a struct rather than a class in C#? When should you use struct and not class in C#? My conceptual model is that structs are used in times when the item is merely a collection of value types.  A way to logically hold them all together into a cohesive whole.  I came across these rules :   A struct should represent a single value. A struct should have a memory footprint less than 16 bytes. A struct should not be changed after creation.   Do these rules work? What does a struct mean semantically?