I have 2 classes and 2 interfaces in my project. In my main(), i have Null Pointer Exception on produce() function. I tried to do produce function to static but it didn't work for me well. Here is my codes, what's the problem ?  This is my CarProjectTest.java codes  import java.util.Scanner;  public class CarProjectTest{     private static int velocity;     private static double time;     private double price;     private CarDecorator carDecorator;     public static void main(String[] args){         String carType;         Scanner user_input = new Scanner( System.in );         // TODO initiate factory!         ICarFactory factory = null;         System.out.print("Lütfen üretilecek arabanın modelini giriniz: ");         carType = user_input.next();         System.out.println(carType);         System.out.print("Lütfen ortalama hızı giriniz: ");         velocity = user_input.nextInt();         System.out.println(velocity);         System.out.print("Lütfen zamanı giriniz: ");         time = user_input.nextDouble();         System.out.println(time);          ICar car1 = factory.produce(carType);          System.out.println("Price: " + car1.getPrice());         System.out.println("Message: " + car1.getMessage(90));         System.out.println("Fuel Consumption: " + car1.getFuelConsumption(100, 1.2));          /*car1 = AirConditioningDecorator(car1); // please read the name carefully and think about the hints         System.out.println("Price: " + car1.getPrice()); // Price should increase by 1000 TL          car1 = AutoShiftDecorator(car1);         System.out.println("Price: " + car1.getPrice()); */     }      //functions         public ICar produce(String carType){         if(carType.equals("TN100")){             carDecorator.setEngineVolume(1.33);             carDecorator.setWeight(768);             carDecorator.setPrice(20000);             carDecorator.setFuelConsumption(velocity, time, 5);                                    }         else if(carType.equals("TN200")){             carDecorator.setEngineVolume(2);             carDecorator.setWeight(900);             carDecorator.setPrice(25000);             carDecorator.setFuelConsumption(velocity, time, 7.2);                                                }         else if(carType.equals("TN300")){             carDecorator.setEngineVolume(2.4);             carDecorator.setWeight(1100);             carDecorator.setPrice(30000);             carDecorator.setFuelConsumption(velocity, time, 9);                                         }         return carDecorator.getDecoratedCar();                                         }  }   and there is my ICarFactory class  public interface ICarFactory {      public ICar produce(String carType);  }   This is the error what i take;  Exception in thread "main" java.lang.NullPointerException     at com.project.factory.CarProjectTest.main(CarProjectTest.java:25)  25th line is: ICar car1 = factory.produce(carType); in Test class
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?
Are there any drawbacks to using a wish spell to increase ability scores? If not then what would stop players from just using wish repeatedly and raising their ability scores to 30?  I'm just getting back into RPGs with D&amp;D 5e after not playing for years, and I seem to remember this being covered in the editions we played back then. PrintWriter and PrintStream never throw IOExceptions Some days ago I realized that  (as well as ) never throw an IOException when writing, flushing or closing.  Instead it sets an internal flag (trouble=true) when an error occurs. It's not possible to get the exact exception, but only if there was some exception ().  My question is: why would one want to have such behavior? Isn't that bad API design? Counting set for generating functions Give  a  proof  of  the  following  identity  by  counting  two  sets  of  partitions  in  two  different ways.  \begin{equation*}  \prod_{i\geq 0}(1+x^{2i+1})=1 + \sum_{n\geq 1}x^{n^2}\prod_{j=1}^n\frac{1}{1-x^{2j}}  \end{equation*} To prove this inductively, i only successfully complete the base cases, however the counting set for the left side i concluded that would be the number of partitions of n with distinct odd parts and for RS the product part would be the number of partitions of n with even parts, how would the summation of $x^{n^2}$ come into play with counting set. How would i initiate my proof? Product of Consecutive Integers is Not a Power What does it mean that a package is "set to manually installed?" When packages are already installed and I run an apt-get install &lt;package-name&gt;, sometimes it will print a line &lt;package-name&gt; is set to manually installed.  What does that mean? Clustering procedure where each cluster has an equal number of points? How can I make a directory on the desktop?  I tried cd /desktop command but it gives an error  no such file or directory.  What's the correct command? I want to attach a code file to my question, but I am not able to find a link to do it. Is attaching files possible at all? install other packages when creating new package in R The following is a geometry puzzle from a math school book. Even though it has been a long time since I finished school, I remember this puzzle quite well, and I don't have a nice solution to it.  So here is the puzzle:    The triangle $ABC$ is known to be isosceles, that is, $AC=BC$. The labelled angles are known to be $\alpha=\gamma=20°$, $\beta=30°$. The task is to find the angle labelled "?".  The only solution that I know of is to use the sine formula and cosine formula several times. From this one can obtain a numerical solution. Moreover this number can be algebraically shown to be correct (all sines and cosines are contained in the real subfield of the 36th cyclotomic field). So in this sense I solved the problem, but the solution is kind of a brute force attack (for example, some of the polynomials that show up in the computation have coefficients > 1000000). Since the puzzle originates from a book that deals only with elemetary geometry (and not even trigonometry if I remember correctly) there has to be a more elegant solution. What is the term for a sentence which reads same forwards and backwards? Please note, I'm not asking for a palindrome.  I mean to say that only the word  order is rearranged, not the actual spelling of the word.  An example might be as follows:     First ladies rule the State and state the rule: ladies first. I was about to add an extra signal handler to an app we have here and I noticed that the author had used sigaction() to set up the other signal handlers. I was going to use signal(). To follow convention I should use sigaction() but if I was writing from scratch, which should I choose? Fundamental group of $S^2$ with north and south pole identified Consider the quotient space obtained by identifying the north and south pole of $S^2$. I think the fundamental group should be infinite cyclic, but I do not know how to prove this.   If it is infinite cyclic, would this and $S^1$ be an example of two spaces which have isomorphic fundamental groups but are not of the same homotopy type? In C the following horror is valid:  myFunc() {   return 42;  // return type defaults to int. }   But, what about in C++? I can't find a reference to it either way...  My compiler (Codegear C++Builder 2007) currently accepts it without warning, but I've had comments that this is an error in C++. Anonymous user feedback now in testing Anonymous and unregistered users with &lt; 15 reputation (the amount required to earn the upvote privilege) will now see       feedback   on every post in the area that a logged in user would see "add comment":    When the post area is moused over, the area expands to:     Was this post useful to you? [Yes] [No]     once clicked it will say     sending feedback...   and eventually     Thank you for your feedback.   The goal is to offer the 90% of our traffic that is anonymous users a way to provide more meaningful feedback on posts rather than passively incrementing a view counter.  This click data is currently being evaluated to see what we can do with it. Ideas welcome! Let a,b,c be positive real number, such that  $\frac{1}{a}+\frac{1}{b}+\frac{1}{c}=a+b+c$. Prove that :  $\frac{1}{(2a+b+c)^2}+\frac{1}{(2b+c+a)^2}+\frac{1}{(2c+a+b)^2} \leq \frac{3}{16}$  Can anyone help me how to deal with it? I have recently upgraded my OS to Ubuntu 18.04 (fresh install via boot device). However, when trying the command:  sudo apt-get upgrade   It works fine until ~75% when it stops and says:  snapd.snap-repair.service is a disabled or a static unit, not starting it.   I'm not quite sure what this means and if I Crtl-Z to get out of it, any time I try to install anything I get:  E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?   and have to restart my computer to install anything. How not to show Universal Access menu Icon in task bar in Ubuntu 18.04? Looking at the kids which - or that/who? We look at the kids which/that/who skillfully use tablets with the help of their small fingers and we understand that to surprise the younger generation will be more difficult each year.   Is the relative pronoun which acceptable here, or does it look totally out of place, because it befits a "non-restrictive relative clause" more?   It seems to me that the pronoun that looks best in the bolded position, with who an acceptable second choice. But it's hard to pin down why. Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?