I want the user to input n numbers of his wish and write a program in java to find the average using arrays. I came up with the following program, but there seems to be a problem when i run it:    Exception in thread "main" java.lang.NullPointerException at wert.main(wert.java:12)  This is the code in question:  import java.util.Scanner; public class wert {  public static void main(String[] args) {     Scanner sc = new Scanner(System.in);     int gucci[] = null;      System.out.print("Enter the length\n");     int n = sc.nextInt();     System.out.println("enter the numbers : ");     for(int i=0;i&lt;n;i++){          int k = sc.nextInt();         gucci[i] = k;         }     int m = average(gucci);     System.out.println(m/n);  }     public static int average(int x[]){         int total = 0;         for(int f: x){             total =+ f;         }         return total;     }    }   I'm sorry if I am asking a really basic question. I started learning java on my own a few days back.
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?
Prove $\alpha \in R[[x]]$ is a unit iff $a_0 \in R$ is a unit Prove $\alpha \in R[[x]]$ is a unit iff $a_0 \in R$ is a unit.   $"\Rightarrow"$ suppose $\alpha \in R[[x]]$ is a unit, where $\alpha = \sum_{n=0}^{\infty} a_nx^n$  then there exists an inverse $\beta = \sum_{n=0}^{\infty} b_nx^n$   stuck at this spot,  $(\sum_{n=0}^{\infty} a_nx^n)(\sum_{n=0}^{\infty} b_nx^n) = \sum_{n=0}^{\infty}(\sum_{k=0}^{n}(a_kb_{n-k}))x^n$  A little mixed up on how this becomes $1 = \sum_{n=0}^{\infty}e_nx^n$ where $e_0 =1, e_{n&gt;0} = 0$ and why that would make $a_0b_0 = 1$ which would make $a_0 \in R$ a unit. I haven't tried the other direction yet.  EDIT  Maybe I get it, because we assumed this sum is a unit then its inverse exists and so the $x^0=1$ and all $a_ib_i=1$ thus $a_0b_0=1$ which gives $a_0$ is a unit in $R$ Continuous probability distribution with no first moment but the characteristic function is differentiable I am looking for an example of a continuous distribution function where the first moment does not exist but the characteristic function is differentiable everywhere.  Cauchy distributions do not fulfill this, as their characteristic functions are not differentiable at $0$. Does anybody here have an example? How do I make an object face the mouse position, but only on one plane? Probability, quantum physics, and why (can't it/does it) apply to macroscale events? Quantum physics dictates that there are probabilities that determine the outcome of an event, ie: the probability of a quark passing through a wall is X, due to the size of the quark in comparison to the wall), but couldn't macroscale events be predicted this same way, assuming all variables were accounted for (lets hypothetically say we have a computer powerful enough to take into account all factors).  My understanding is that as the scale of an object increases, the probability of it doing anything other than what classical physics dictates is almost 0%, but could conceivably do something not predicted (Example: a human being cannot pass through a wall, but given an infinite timescale, eventually s/he would because of probability not being 0). Is this accurate? If so, then shouldn't we, (except as a tool for conceptualization, like how we round 9.8 m/s^2 or pi to 3.14), use only quantum mechanics to explain events in any scale (for more accuracy)? Why can Naruto still use Rasenshuriken? When Naruto first used Rasenshuriken against Kakuzu the effect was massive. He destroyed   two of Kakuzu's hearts, but there were a huge after effect to him. If I'm not mistaken, Tsunade advised Kakashi to ask Naruto never to use the technique again due to the huge risk. So why is Naruto still able to use the technique and have no side effects after that battle? I may have missed out on something. Create taxonomy terms on the fly Does "a couple" always mean two? I was listening to the song  by Eminem. I've listened it before many times but from the time I've started learning English grammar I am getting confused while reading or listening English. This time I got stuck at the line "Too much pride, between you and I Not a jealous man but females lie". The phrase "between you and I" always sounded correct to me. But recently I learned that me is only used as an object and hearing that phrase sparked my head. Then I searched over the net and found on  that it is actually a hypercorrection.  says,      "...according to many grammarians and stylists a pronoun in a prepositional phrase in English is supposed to be in the oblique case...   ...though there is still disagreement on whether the phrase itself in today's language is grammatically correct or not."   My first question is, why is there a disagreement? Don't we always use the object form in the oblique case? If not then what are those cases?  Secondly, I want to know how common the phrase "between you an I" is? Is it used colloquially by common native English speakers. By common speakers I mean who don't bother grammar. I searched on  and got some results, e.g. . I found the phrase in another song -- . Is it a common mistake among native English speakers or is it used to give some special linguistic affect? I think this phrase has some linguistic affect that is why the singer would have given the name of her song "Between You and I". Because no one would like to use incorrect English in the title of a song, it must have some purpose. Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index (1) in Python? This is more of a panic question after reading reviews on Istanbul Atatürk Airport. They said it's messy and hard to navigate, therefore I'm asking questions here in name of my girlfriend who will need to transit through this airport.  My girlfriend (Canadian national) traveling from Toronto (YYZ) to Istanbul (IST) for a couple hours (~4 hrs, so transiting) in order to come to Pristina (PRN). I would like a quick guideline on how to pass through this airport seamlessly without facing any trouble or delay.  Her tickets are both with Turkish Airlines. She purchased it via a third party (Flighthub.ca). It's only one booking and it includes both flights in it.   Once my girlfriend departs, she's obviously required to follow the signs and go to the transit area. Once she's there, will she be required to present a ticket? Where does she get that ticket? Does she get it in YYZ or does she need to visit a counter in IST and get it? After she's got the proper ticket, what does she need to do exactly? Wait in line to have her passport checked? Will they also control her carryon?  After this step, does she simply go to the PRN flight gate and that's it?   We're simply worried about Istanbul Atatürk Airport because of the recent things that happened in Turkey (coup attempt and ISIS attack) and she doesn't wanna somehow end up locked up there. I've read that the airport is a mess lately and a lot of people will be there waiting in line. So, another question: Are 4 hours enough?  I would appreciate a step by step guideline on how she needs to navigate and what she needs to do in that airport to have a smooth experience without facing any delays. Also some misc information on Istanbul Atatürk Airport would be appreciated. I've used recursion quite a lot on my many years of programming to solve simple problems, but I'm fully aware that sometimes you need iteration due to memory/speed problems.  So, sometime in the very far past I went to try and find if there existed any "pattern" or text-book way of transforming a common recursion approach to iteration and found nothing. Or at least nothing that I can remember it would help.   Are there general rules? Is there a "pattern"? I read a book that answers one of my questions, and I would like to quote it as an answer. Is that illegal?    Thanks. How are the number of views in a question calculated? Why do we need to dummy code categorical variables How do I use sudo to redirect output to a location I don't have permission to write to? I've been given sudo access on one of our development RedHat linux boxes, and I seem to find myself quite often needing to redirect output to a location I don't normally have write access to.  The trouble is, this contrived example doesn't work:  sudo ls -hal /root/ &gt; /root/test.out   I just receive the response:  -bash: /root/test.out: Permission denied   How can I get this to work? Why would Voldemort spare Lily? In one of Harry's dementor-induced flashbacks, he presumably hears his mother protesting against Voldemort:  Harry was falling again through thick white fog, and his mother’s voice was louder than ever, echoing inside his head – ‘Not Harry! Not Harry! Please – I’ll do anything –’ ‘Stand aside – stand aside, girl –’ ‘Harry!’  Voldemort tells her to stand aside - why did he not just kill her? I'm considering buying a subscription to Minecraft Realms (on PC) as a gift for somebody I know. Mojang doesn't have a gift option, and I don't want to spoil the surprise, so I was thinking I'd just buy it myself and give them access.   If I do this, will the recipient be able to turn around and invite their own friends? Can I grant them "admin" access to the server? MathJax isn't currently working on the Android app, which makes it totally useless for the 'technical' sites like  or .  For example, in the Android app:    Same post in a (mobile) browser:     Please add this functionality! For groups $A,B,C$, if $A\times B$ and $A\times C$ are isomorphic do we have $B$ isomorphic to $C$? The motivation for this question is in my answer to this post :       (1) If I take $A$, $B$ and $C$ three groups such that $A\times B$ is isomorphic to $A\times C$ then do we have $B$ is isomorphic to $C$ ?   In the post a counter example is given when $A$ is an infinitely generated group. However I cannot get a counter-example when $A$, $B$ and $C$ are assumed to be finite groups. Note that there is no reason a priori if $\phi$ is an isomorphism from $A\times B$ to $A\times C$ that $\phi(A\times\{1_B\})=A\times\{1_C\}$.   In the case of finite groups it is true because of the Krull-Schmidt theorem : .  A slightly more general question is the following :     (2) If $B$ and $C$ are two finitely generated groups, can I always find a finitely generated group $A$ such that $A\times B$ is isomorphic to $A\times C$?   If $A$ is not assumed to verify any property but to be a group we can take :  $$A=B^{\mathbb{N}}\times C^{\mathbb{N}} $$  Furthermore replacing :$ \prod_{\mathbb{N}}$ by $\bigoplus_{\mathbb{N}}$ (or more likely the restricted product for groups but I am not sure of a well known notation, it is the subgroup of the product with all but a finite number components being trivial) will give you the same result for countably infinite groups.   $\underline{\text{Edit}}$ : To be clear about what I am asking. (1) is kown to be true for finite groups whereas (2) is known to be true when we are considering groups without restriction (even just for countably infinite groups). Let us pretend we are working on the smaller class of groups : the finitely generated groups. Is there any counter example to $(1)$? Is there any counter example to $(2)$?   $\underline{\text{Edit 2}}$: Here is a partial answer, from the classification of finitely generated abelian groups $(1)$ is always true if all groups are assumed to be abelian finitely generated groups. Now assume that $A\times B=G=A\times C$. Then you have (derived groups) :  $$D(G)=D(A)\times D(B)=D(A)\times D(C) $$  So the abelianizations verify :  $$A^{ab}\times B^{ab}=A^{ab}\times C^{ab}$$  Because we are now in the realm of finitely generated abelian groups we get :  $$B^{ab}=C^{ab} $$  So $(2)$ cannot be true in general for instance you can take $B:=\mathbb{Z}$ and $C=\mathbb{F}_5$, those two groups have different abelianizations.   The new question can be found here : I've heard many times that it's bad to use display: none for SEO reasons, as it could be an attempt to push in irrelevant popular keywords. A few questions:   Is that still received wisdom? Does it make a difference if you're only hiding a single word, or perhaps a single character? If you should avoid any use of it, what are the preferred techniques for hiding (in situations where you need it to become visible again on certain conditions)?   Some references I've found so far:       If you're straight-out using CSS to hide text, don't be surprised if that is called spam. I'm not saying that mouseovers or DHTML text or have-a-logo-but-also-have-text is spam; I answered that last one at a conference when I said "imagine how it would look to a visitor, a competitor, or someone checking out a spam report. If you show your company's name and it's Expo Markers instead of an Expo Markers logo, you should be fine. If the text you decide to show is 'Expo Markers cheap online discount buy online Expo Markers sale ...' then I would be more cautious, because that can look bad."   And  on the same article     We can flag text that appears to be hidden using CSS at Google. To date we have not algorithmically removed sites for doing that. We try hard to avoid throwing babies out with bathwater.   Eric Enge      The legitimate use of this technique is so prevalent that I would rarely expect search engines to penalize a site for using the display: none attribute. It’s just very difficult to implement an algorithm that could truly ferret out whether the particular use of display: none is meant to deceive the search engines or not.