I can't figure out how to fix the nullpointererror in Java I am writing a program that takes a file and writes it's contents to an array. Then the array is sorted with a selection sort algorithm and then can be searched using the binary search algorithm. The array can not have more than 100 elements and I can't use user-defined classes.  /*Griffen Fox   CS 110   Assignment 5   Question 1 */ import java.util.Scanner; import java.io.*; public class WordsSearchProgram {    public static void main(String[] args)throws IOException    {       //Loads Words.txt to an array       final int SIZE = 100; //Size of the array       String[] words = new String[SIZE]; // creates the array       int index = 0; // Loop Control Variable        //Opens the File       File file = new File("words.txt");       Scanner inputFile = new Scanner(file);        //Reads Contents Into Array       while (inputFile.hasNext() &amp;&amp; index &lt; words.length)       {          words[index] = inputFile.nextLine();          index++;       }        //Close File       inputFile.close();       int search;       for (index = 0; index &lt; words.length; index++)         {            search = searchString(words, words[index]);             if (search &gt;= 0)           {               System.out.println(words[index] + " is at index " + search);            }            else           {               System.out.println(words[index] + " is not in the array.");            }          }       }     //Selection Sort Algorithm     public static String[] sort(String[] words)     {       for (int i = words.length - 1; i &gt;= 1; i--)       {        // Find the maximum in the list[0..i]        String  currentMax = words[0];        int currentMaxIndex = 0;           for (int j = 1; j &lt;= i; j++)          {             if (currentMax.compareTo(words[j]) &lt; 0)              {                currentMax = words[j];                currentMaxIndex = j;             }          }         // Swap list[i] with list[currentMaxIndex] if necessary;        if (currentMaxIndex != i)         {          words[currentMaxIndex] = words[i];          words[i] = currentMax;        }        }       return words;       }       //Binary Search String       public static int searchString(String[] words, String key)        {            int first = 0;            int last  = words.length;          int position = -1;          boolean found = false;             while (!found &amp;&amp; first &lt;= last)          {               int mid = ((first + last) / 2);               if (key.compareTo(words[mid]) == 0)              {                  found = true;                position = mid;               }             else if (key.compareTo(words[mid]) &gt; 0)              {                  first = mid - 1;               }              else              {                  first = mid + 1;               }              }            return position;         } }
What is a NullPointerException, and how do I fix it? 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?
pygame.event.get() not returning any events when inside a thread How to detect character sets encoding for all of language? I want to overlay one image with another using CSS. An example of this is the first image (the background if you like) will be a thumbnail link of a product, with the link opening a lightbox / popup showing a larger version of the image.   On top of this linked image I would like an image of a magnifying glass, to show people that the image can be clicked to enlarge it (apparently this isn't obvious without the magnifying glass). Can a wizard using an arcane focus quarterstaff and a shield still cast somatic component spells? If there is a wizard that, by some means, has acquired proficiency in the use of shields, can said wizard use his shield in one hand and his arcane focus quarterstaff in the other and still cast somatic component spells?  Since the quarterstaff has been crafted to also be an arcane focus, and the Sage Advice Compendium states that you can provide the somatic components of spells with the same hand wielding the arcane focus, in this case an arcane focus quarterstaff, could that wizard still be able to perform somatic component spells while using a shield in the other?  I understand War Caster is the feat that allows you to cast somatic component spells even while using a shield and weapon or two weapons in each hand, but is this a simple way around those rules seeing as this "weapon" is your arcane focus? I would like to believe it is not, but I'm not fully fluent in the ways of spellcasting. Possible Duplicate:          Please, look at the picture?    Which calculator shows true result and how to prove achieved result? Eigenvectors of real symmetric matrices are orthogonal Shell script to delete directories older than n days systemctl --user not available for www-data user systemctl --user seems to be working fine for the desktop user:  dev@dev-VirtualBox:~$ systemctl --user &gt; /dev/null dev@dev-VirtualBox:~$ echo $? 0   But when running the same command under the www-data user I get an unexpected response  dev@dev-VirtualBox:~$ sudo su www-data -s /bin/bash www-data@dev-VirtualBox:~$ systemctl --user &gt; /dev/null  Failed to connect to bus: No such file or directory  www-data@dev-VirtualBox:~$ echo $?  1   How to enable systemctl --user here?  Running Ubuntu 16.04 I am rebuilding an old server.  Only one of the five old sites need to go live and all five of the old sites point to the same IP address.  Unfortunately any time a request is made for one of the old sites via their own unique domain names they are passed the pages from the one site that I'm trying to make live.  I would just like the old sites to display a 404 instead of the one site that I'm actually trying to make live.  As an example:   Site 1 (192.168.0.1) [www.first.com] Site 2 (192.168.0.1) [www.second.com] Site 3 (192.168.0.1) [www.third.com]   I want to move site 1 live again.  So I turned on apache on the machine with the IP address of 192.168.0.1, with all of site 1's files in the /var/www directory.  When I browse to 192.168.0.1 or www.first.com I correctly see site 1. When I browse to www.second.com and www.third.com I also receive site 1 which is the problem.  Is there a way I can 404 any request which comes in without www.first.com?  Here is my sites-available:  NameVirtualHost *:80  LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common  &lt;Files ~ "^\.ht"&gt;     Order allow,deny     Deny from all     Satisfy All &lt;/Files&gt;  &lt;Directory /&gt;   Order Deny,Allow   Deny from all   Options None   AllowOverride None   Options None &lt;/Directory&gt;  &lt;Directory /var/www&gt;   Order Allow,Deny   Allow from all &lt;/Directory&gt;  &lt;VirtualHost *:80&gt;         ServerName first.com         ServerAlias www.first.com         DocumentRoot /var/www         ErrorLog /var/log/first.com.err         CustomLog /var/log/first.com.log common &lt;/VirtualHost&gt;  &lt;VirtualHost _default_:*&gt;         ServerName unknown         DocumentRoot /var/www_404 &lt;/VirtualHost&gt; What do I need to install LED strip lighting? I've been looking to install LED strips, either RGB or white for lighting and ambiance. It wouldn't be the main lighting of the room, so no necessity for high power LEDs.  The perimeter of the room is a little less than 25 meters. Looking around in online stores, I saw that the reels come in maximum lengths of 5 meters, so I would need five of those.  What I'm not sure is how to connect the strips together.  I was looking at , or  with .  If I choose the white LEDs, what power supply, controller, and connector would you recommend to be able to daisy chain the strips?  If I choose the RGB LEDs, what kind of data repeaters would work to be able to control all the strips at once? Nicely force 66 characters per line Accoring to Joseph Wright's answer at   The k-type argument has recently been adjusted: you now want e-type  Questions:  What is the functionality of the new e-type argument and how does it differ from the previous k-type argument?  The 2016-11-21 version of the xparse documentation does not mention the k-type argument at all. Is the plan to leave the earlier k functionality intact (but deprecated so no documentation) or will it eventually be removed and any usage of that should eliminated? If the plan is for it to be removed, how long will the older k-type argument functionality be kept in xparse.   Code: Example of the k-type argument from . Would be useful to see how this would be modified to use the new e-type argument. \documentclass{article}  \usepackage{amsmath} \usepackage{xparse} \usepackage{xcolor}  \NewDocumentCommand\MyMacro{k_}{%     \IfNoValueTF{#1}{%         \mathbf{A}     }{%         A_{\textcolor{red}{#1}}     }% }  \begin{document}  With a subscript: $\MyMacro_{\pi}$   Without any subscript: $\MyMacro$   \end{document} How do I dynamically create the variable name in a PHP loop? How would I shift my whole set of equations/calculations at the left, to be aligned with "Example"?        \documentclass[11pt,a4paper]{report} \usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array} \usepackage{parskip}   \theoremstyle{plain} \newtheorem{thm}{Theorem}[chapter] % reset theorem numbering for each chapter \newtheorem{lem}[thm]{Lemma} \newtheorem{prop}[thm]{Proposition} \newtheorem*{cor}{Corollary}  \theoremstyle{definition} \newtheorem{defn}[thm]{Definition} % definition numbers are dependent on theorem numbers \newtheorem{exmp}[thm]{Example} % same for example numbers \newtheorem{conj}[thm]{Conjecture}  \theoremstyle{remark} \newtheorem*{rem}{Remark} \newtheorem*{note}{Note}   \title{My Thesis Title} \author{My Name} \date{\today} \renewcommand\labelenumi{(\theenumi)} \renewcommand\theenumi{\roman{enumi}} \setlength{\parindent}{1em}  \begin{document}  \chapter{Addition}  \begin{exmp}  Here is an example. \begin{align} \nonumber (a+b)^3 &amp;= (a+b)^2(a+b)\\ \nonumber &amp;=(a^2+2ab+b^2)(a+b)\\ \nonumber &amp;=(a^3+2a^2b+ab^2) + (a^2b+2ab^2+b^3)\\ \nonumber &amp;=a^3+3a^2b+3ab^2+b^3 \nonumber \end{align} \end{exmp} \end{document} I ajaxly call a route and pass data to it, In my controller, I want to get $_POST['var'] , $_POST['var2'], it seems because of using HttpFoundation in drupal 8, $_POST and $_GET are not exists in old method, How I can access $_POST parameters in custom Controller? Conditionally use 32/64 bit reference when building in Visual Studio May someone help me? I am trying to use induction to prove that the formula for finding the $n$-th term of the Fibonacci sequence is:   $$F_n=\frac{1}{\sqrt{5}}⋅\left(\frac{1+\sqrt{5}}{2}\right)^n-\frac{1}{\sqrt{5}}⋅\left(\frac{1-\sqrt{5}}{2}\right)^n.$$  I tried to put $n=1$ into the equation and prove that if $n=1$ works then $n=2$ works and it should work for any number, but it didn't work. I need to prove that this formula gives the $n$th Fibonacci number. What is the limit of Lovers Leap? Using differentiation for computing $\int_{0}^{1}\frac{\arctan(ax)}{x\sqrt{1-x^2}}\,dx$ How can I prove that I can differentiate the integral:  $$ \int_{0}^{1} \frac{\arctan(ax)}{x\sqrt{1-x^2}}\,dx $$  First I have to prove this integral converges. Next I have to prove the integral $$ \int_{0}^{1} f_{a}'(x, a)\,dx $$ converges uniformly.  Then I can differentiate integral with Leibniz's rule.  I tried Weierstrass and Dirichlet's tests. Nothing succeeded.   Thank you for help in advance. I'm trying to continue the numbering of examples in enumerate environments in beamer. For example, I'd like one slide to feature   Foo Bar   and the next slide   Zip Yadda   My strategy so far has been to define a counter that saves the enumerate counter at the end of the first environment and can then be queried to set the enumerate counter at the start of the second enumerate environment. (This is essentially the proposal also found at )  That works wonderfully so long as I don't try to uncover elements of the slide sequentially. The problem, of course, is that as each of the pdf-pages that make up the slide is created, the counter is advanced. Here's a MWE.  \documentclass{beamer}  \setbeamercovered{highly dynamic}  \newcounter{saveenumi} \newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}} \newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}   \begin{document}  \begin{frame}[&lt;+-&gt;]   \begin{enumerate}   \item foo   \item bar%     \seti   \end{enumerate} \end{frame}  \begin{frame}[&lt;+-&gt;]   \begin{enumerate}     \conti   \item zip   \item yadda%     \seti   \end{enumerate} \end{frame}  \end{document}   As the second slide is progressively uncovered (pages 3 and 4 of the resulting PDF), the counter at the beginning of the enumerate environment is advanced each time. So page 3 of the PDF has the right numbering, (3) and (4) respectively, while the fully revealed page has the wrong numbering. Pictures follow:   on one of the slides    on the following one