I did wrote a code that gets a text file as input, then the program makes to equal String arrays with the text so the words can be compared and find + count the unique and repeated words. The program becomes compiled successfully but if I try to execute it so I get the problem: Exception in thread"main"java.lang.NullPointerException...java:52. The problem must be in the way I declare the strings. How should I write them instead? Thanks!  import java.util.*;  class TextAnalyze{ public static void main(String[] args){ In read = new In ("text1.txt"); //input *.txt file      int tWords = 0; // counter, total words in the text file     int unW = 0; //counter UNIQUE words in the text file     String[] word = new String[31000]; //array with all the words     String[] word2 = new String[31000]; // array with all the words, used to compare     //String uniqueWords[] = new String[31000]; //array with the unique words     //int numberuniqueWords[] = new int [31000];      while(read.endOfFile() == false) {          word[tWords] = read.inWord();         word2[tWords] = word[tWords];         tWords++;      }      int totalWords = word.length;     int totalWords2 = word2.length;      List&lt;String&gt; uniqueWords = new ArrayList&lt;&gt;();      for (int i = 0; i &lt; totalWords; i++) { // loop of the first array list         boolean unique = true;          for (int j = 0; j &lt; totalWords2; j++) { // second loop where the                                         // words are being compared             if (word[i].equals(word2[j])) {                 //we find two equals strings, it not unique                 unique = false;                 break;             }         }          //if it remains unique there wasn't equals         if (unique) {             uniqueWords.add(word[i]);         }     }      for (String s : uniqueWords) {         System.out.println(s);     }  }   }
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?
I have been editing an answer on , with some considerable amount of effort, and when I hit on Save Edits, the edit gets rejected with the following error. I got to know the meaning of this from .     The edit queue is full at the moment - try again in a few minutes!     I tried in a few mins, and still it didn't work. I believe that some edits might be valuable and this resists the users from doing so.   Main Question: Is there a way to show the queue limit at the beginning of the editing process? (So that we won't spend time on doing the edit, knowing it will fail) No more updates for Google Chrome 32-bit The first given name of an author or editor in my bibliography should be written out, but all further first names should be abbreviated (initials with a period -- and space if there are multiple first names/initials, see below). I am using style=authoryear with BibLaTeX (v. 2.7) and Biber (v. 1.7).  My bibliography looks like this:     Doe, John Arthur Kyle (2013). The secret life of John Doe.   It should look like this:     Doe, John A. K. (2013). The secret life of John Doe.   Minimal example:  example.tex  \documentclass{scrartcl}  \usepackage[ngerman]{babel} \usepackage[babel,german=quotes]{csquotes} \usepackage[backend=biber,style=authoryear]{biblatex} \bibliography{bibliography}  \begin{document}  \cite[123]{Doe} \printbibliography  \end{document}   bibliography.bib  @book{Doe,     title = {The secret life of John Doe},     author = {Doe, John Arthur Kyle},     year = {2013} }   (Worked with said versions of BibLaTeX and Biber, Texmaker (v. 4.0.3) and MiKTeX (v. 2.9.4813).)  I could not find a solution in biblatex.def and firstinits=true abbreviates all first names, including the first one. Reinstall Windows 8 on a Windows 8 based system with embedded key I'm a computer technician and we started selling few Windows 8 machine. We saw the new COA label does not show the key and after reading a little bit online, realized those systems came with the key emmebeded in the eUFI BIOS.   My question is : How do I reinstall Windows 8 if the hard drive is crashed? I kind of get that you can install it with a media and the media should activate the licence embedded. What is the media required? Is a retail DVD is able to do the work or do I need a system builder kit? I understand the manufacturer is reponsible to provide media  or replace the failed drive under the warranty but what will happen when warranty expire? I'll have to sell a full windows 8 licence with a key?  Thanks "Easy" vs. "simple" Are those two words equivalent or is there a difference? When would I say something is easy rather than simple, or vice versa? How to check type of variable in Java? This question has been asked before, at least twice by people who were trying to cheat on the PROMYS Europe 2020 Application, and once in a  because the OP showed no effort. I haven't been able to solve it, so I'm going to to ask it again.  PROMYS applications have closed, and I hope the effort shown below is enough to keep this question from being closed.     The Mathematical Forest is grown in a two-dimensional plane, where   trees can only grow on points with integer coordinates. To start with,   there are no trees at all. The foresters plant the first tree at   $(0,0)$. Each year, they carry out tree planting according to the   following rule. If there is a tree on the point (𝑚,𝑛) but there are   no trees on the points $(m+1,n)$ and $(m,n+1)$, then they can choose   to remove the tree on $(m,n)$ and plant new trees on the points   $(m,n+1)$ and $(m+1,n)$. For an integer $k\geq1$, the $k$th diagonal   consists of all points $(m,n)$ with $m+n=k−1$. Is it possible for the   foresters to arrange their planting so that eventually there are no   trees on the first $2$ diagonals? What about the first $3$ diagonals?    $4$ diagonals? Can you generalize?   It's easy to get to a position with no trees on the first two diagonals.  (It only takes $4$ plantings.)  I can prove it's impossible to reach a position with no trees on the first $4$ diagonals, and I believe it's impossible to reach a position with no trees on the first $3$ diagonals, but I can't prove it.  For the $k=4$ case, I used a pagoda function, as in a peg solitaire problem.  For $k=1,2,3,\dots$ define the potential of a tree on the $k$th diagonal as $\frac1{2^{k-1}}$, and the potential of the forest as the sum of the potentials of all the trees in it.  When a tree of potential $\frac1{2^{k-1}}$ is removed, it is replaced by $2$ trees of potential $\frac1{2^k}$ so the potential of the forest never changes.  Initially, the potential of the forest is $1$.  Since there are $k$ trees on diagonal $k$, the potential of all points beyond the fourth diagonal is $$\sum_{k=5}^\infty\frac k{2^{k-1}}=\frac34&lt;1,$$ so it is impossible that there are no trees on the first $4$ diagonals.  The potential of the fourth diagonal is $\frac12$, so this argument doesn't show that it's impossible to have no trees on the first $3$ diagonals.  I've done a lot of experimenting, though, and I believe that the statement is true.  (I even wrote a little computer game so I could experiment quickly.)  The best I've been able to do is to get down to one man on the third diagonal.   The black circles are trees eligible for removal, and the gray circles are other trees.  You can see that there is a "traffic jam" in front of the lone tree on diagonal $3$, and there seems to be no way to clear it.  I've been trying to come up with an argument that reflects this traffic jam, but I haven't been at all successful. We know that after $n$ removals there are $n+1$ trees, and I've been trying to prove somehow that they can't all be sufficiently far from the origin to allow all trees to get past diagonal $3$, but I haven't come close.   In the diagram above, if the tree at $(1,1)$ were moved to $(0,2)$, and the tree at $(1,2)$ were moved to $(2,0)$, then it would be possible to remove the tree at $(0,2)$, emptying the second diagonal.  In the fictitious position, we still have one tree on diagonal $2$ and two on diagonal $3$.   So, I think an argument along the lines I was trying cannot just be concerned with the distance from the origin; it must somehow take into account how the trees interfere with one another.  I haven't been able to do this.    I'd be grateful for solutions, hints, or counterexamples.  I wasn't really sure what tags to attach.  Please add any that seem appropriate. There is a way to use my Galaxy tab s like a wacom table, on linux? How to make a declaration from a command? There are two forms of setting the type style: the declarative method e.g, \itshape and the command form, e.g, \textit. The command form takes an argument whereas the declarative form does not --- it just applies itself to whatever comes afterwards.  I would like to develop a declarative form, say \UppercaseIt, of the command form \MakeUppercase{&lt;text&gt;}. I have read, in source2e.pdf on CTAN the code for implementing \textit, \itshape and \MakeUppercase and can't claim that I understand any of them. I am after something like {\UppercaseIt some text} instead of \MakeUppercase{some text}.  I only have a code outline of what I'm after, since I don't know how to do it:  \documentclass{article}  \newcommand{\UppercaseIt}{%   %... magic }  \begin{document}  \MakeUppercase{some text}% Yields SOME TEXT  {\UppercaseIt some text}% Should yield SOME TEXT  \end{document} Are there any more Asgardians? How to install gnome shell extensions offline? I know how to go to the  website and download gnome-shell extensions, but now I need to install some extensions available there on a computer without any internet access at all. It is in a internal corporate network and there's no way I can get outside internet access on it, so I must find another way. I can copy files in a usb disk.   At my home computer, I have found my extensions at ~/.local/share/gnome-shell/extensions/ but just copying this folder to the target corporate computer didn't do the trick.   Running gnome-tweak-tool gives me a "Install Shell Extension" button but I don't know how to download an extension in a format acceptable to install using this button. I have tried to point to the folder above but it didn't work either.  What do I need to do? Why are there directories called Local, LocalLow, and Roaming under \Users\\AppData? I have a workstation running Windows Server 2008 that's logged into an  domain, and I have a dual boot with Ubuntu Linux. When running Linux, I'd like to be able to use the same Thunderbird profile I use under Windows, so I pointed Thunderbird to use a profile I found under:  \Users\(myname)\AppData\Local\Thunderbird\Profiles   It turns out it was not the correct profile -- it had the right configuration, but the Inbox was an old version. I eventually found out the correct path was:  \Users\(myname)\AppData\Roaming\Thunderbird\Profiles   What's the rationale behind those different places to store application data? What is the best way to filter a Java Collection? Let $b_n$ decrease monotonically to zero, prove $\sum b_nz^n$ converges for $|z|\leq 1$ and $z\neq 1$ Position of "only" in “We 𝒐𝒏𝒍𝒚 have two possibilities” Is there any difference in meaning between the three following sentences?   We only have two possibilities. We have only two possibilities. We have two possibilities only.   I have already read  and I know that the position of only and the emphasis (written or oral) may change the meaning of some sentences, but I am not sure if it does here.  Note: It is clear that “only we have two possibilities” has a different meaning. My question is restricted to the sentences I’ve listed above. I have lost my passport here in Beograd. Can I travel just with my Czech ID card from Belgrade to Budapest? Problem with packages subfiles and import.sty after using TexLive Utility for updating Everything worked fine before using TexLive for updating my packages three days ago. Now it is not possible anymore to use the package subfiles   Here are the MWE  The minimum Preamble.tex file  \documentclass{amsart} \usepackage{subfiles}   The MWE.tex file  \documentclass[MWE.tex]{subfiles} \begin{document} MWE \end{document}   When I compile the MWE file I get on the console  This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded &gt;format=pdflatex)  restricted \write18 enabled. entering extended mode  (./MWE.tex  LaTeX2e &lt;2020-02-02&gt; patch level 5  L3 programming layer &lt;2020-02-25&gt; (/usr/local/texlive/2019/texmf-dist/tex/latex/subfiles/subfiles.cls  Document Class: subfiles 2020/02/14 v16 Multi-file projects (class)  Preamble taken from file `MWE.tex'  (/usr/local/texlive/2019/texmf-dist/tex/latex/tools/verbatim.sty)  (/usr/local/texlive/2019/texmf-dist/tex/latex/import/import.sty)  ! LaTeX Error: File `import.sty' not found.  Type X to quit or &lt;RETURN&gt; to proceed, or enter new name. (Default extension: sty)  Enter file name:   I checked and the import.sty file is in the right directory, and everything worked fine before. Do you have any idea about what happened (apart from the fact that I should not upgrade stuff before the official releases of TexLive I suppose  ...)? I'm entering the world of Linux and at work I'm using grep more and more.  By doing that I'm figuring out that sometimes it's not adequate for what I want.  I was struggling with grep a few days ago and a colleague of mine who is a senior Linux admin, told me to use awk. I was stunned by how fast I got a result.  So my question is when do you choose to use one over the other? What questions can I ask myself before going to work with grep and spending a lot of time, when I could have done it with awk and saved time? I was recently in a bit of a quandary over which answer to accept to .  Of the answers I got, two were the clear leaders and, of course, I up-voted both. Choosing a 'winner' was more difficult though as their approaches were quite different.  Answer A addressed my question and provided a clear and well thought out response. I'd anticipate that this answer would be of most use to a user who found my question via a search. Selecting this would probably be the more community-focused way to go.  Answer B took a more lateral approach and made some guesses at the business logic behind my request, suggesting that I might be asking the wrong question. Their solution was based on this assumption - and they were spot on. Answer B formed the basis of my fix for the problem.  So... Best answer to the question or best solution to the problem - they may not always be the same thing.   I took the selfish approach and went with B. I'm not losing sleep over it, but I do wonder if I did the right thing? Since upgrading to OS X El Capitan, I've noticed a change in the Terminal: Executed lines show an opening bracket on the left, and a closing bracket on the right, as shown in this screenshot:    Similar questions have been asked here:          Some of the questions are referring to these brackets as marks, and the Terminal's Edit menu has a couple of entries related to marks, for example:   Edit > Marks > Mark as Prompt and Send Return Edit > Clear to Previous Mark Edit > Navigate > Jump to Previous Mark     Is there a summary of what these marks can be used for? I have not seen any reference to this new feature in any of the El Capitan feature overviews.