I have written a simple code to read a 2d integer array of size n1 and n2 and print the middle element in java. import java.io.*; import java.lang.*; import java.util.*; public class Main {     public static void main(String args[])throws IOException {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         int n1=Integer.parseInt(br.readLine());         int n2=Integer.parseInt(br.readLine());         int[][] arr=new int[n1][n2];         System.out.println(&quot;n1&quot;+n1+&quot;n2=&quot;+n2);         String[] sarr=new String[n2];         for(int i=0;i&lt;n1;i++) {             sarr = br.readLine().split(&quot; &quot;);//line 13             for (int j = 0; j &lt; n2; j++)                 arr[i][j] = Integer.parseInt(sarr[j]);         }         System.out.println(arr[n1/2][n2/2]);     } }  I was getting the below error in an online compiler but when executed in intellijIDEA there was no error. Exception in thread &quot;main&quot; java.lang.NullPointerException     at Main.main(Main.java:13)
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?
Additive Roman Numeral 4 I am working on a diplomatic edition of a 15th century book and it numbers its folios using the standard roman numerals of the time.  I've been using the following to get the page/folio in my header:  \newcommand{\rectoverso}[1]{\ifthenelse{\isodd{#1}}{r}{v}} \newcommand{\folio}[1]{\the\numexpr (#1+1)/2\relax} \uppercase\expandafter{\romannumeral \value{\folio{\thepage}}}\rectoverso{\thepage}   This works great, but the problem is that the roman numeral sequence is off of what I need.  Instead of I, II, III, IIII, V, VI, VII, VIII, IX, X, I get the subtractive IV (somewhat understandably, given it's the far more common one in modern usage).  My source text only (and always) uses the additive 4 in the one's position: 24 is XXIIII, 34 is XXXIIII but 44 is XLIIII.  9 is universally rendered subtractively as IX or XC.  Is there a package that allows for some control over which numbers are done additively and which are subtractively, or would my best option be to write my own custom definition to account for the specific style used in my book? How do I check if an array includes a value in JavaScript? Frequency encoding is a widely used technique in Kaggle competitions, and many times proves to be a very reasonable way of dealing with categorical features with high cardinality. I really don't understand why it works.   Does it work in very specific cases where frequencies are correlated with the target or is it more general? What's the rationale behind it? Thought Experiment - Poking a stick across a Black Hole's Event Horizon The classical explanation of a black hole says that if you get to close, you reach a point - the event horizon radius - from which you cannot escape even travelling at the speed of light. Then they normally talk about spaghetti.  But here's a thought experiment. What if I have a BH with event horizon radius R such that the gravitational gradient at the event horizon is far too weak for creating pasta. I build a Ring with radius R+x around the BH. Then I lower a pole of length x+d from my ring towards the BH, so that the tip passes beyond the event horizon.  Now what happens when I try to pull the pole back? Could someone explain the muon $g-2$ experiment problem? How to use Alt+Shift to switch keyboard layouts? I recently upgraded to Ubuntu 13.10, with the new keyboard handling system. The little "switch keyboard" option does not let me set it to Alt+Shift. How can I get this keyboard binding, as I have absolutely no interest in using the Mac-esque Super+Space combo? How to install Tor? Where can I find sample or real Selenium projects. All the material I can find on github and on internet are basic, and never intermediate or advanced.  How does a real Selenium project look in real life? How can I find sample code? Why can a discontinuous function not be differentiable? "A quarter past five" or simply "Quarter past five"? I usually say “It’s a quarter past” (for instance) “five”.  But I think I’ve heard (or read) “It’s quarter past ...”, too, with no indefinite article: is that correct?  Which is more common (if both constructions are in use)?  Is the omission of the article more colloquial (informal, popular, whatever)?  Is there a difference between British and American English?  Thank you very much. How to access a variable from another script in Unity c# I'm downloading GTA V. After 20gb / 100gb I paused my download for restarting my pc. Then download restarts from 0%.  Why this could happen? Can I restart my PC during downloads without losing progress? Automatically turn on VPN on computer unlock Ubuntu 18.04 When I wake the laptop from the sleep I need to get the VPN state as I left it (turned on). Can't find the setting of autoconnect in VPN settings... Need some easy way to ask the system to autoconnect the VPN when the internet is available.  Edit based on comments:  Ubuntu 18.04 has no option to Always connect to VPN when using using this connection. Definitions of "linearity" across branches of mathematics or levels of math education Linearity is a ubiquitous concept in mathematics; however, each branch of mathematics appears to have its own definition of what a linear map (function, functional, functor, transformation, form, operator, or whatsoever) is. These different definitions can lead to confusion, especially when people apply conflicting definitions of linearity to the same mathematical object (just  to figure out what I mean).  One of my favorite examples with potential for conflict is the natural logarithm $\ln : \mathbb{R}_{&gt;0} \to \mathbb{R}$, which the majority of people, as I could learn during hot disputations not only  but also with colleagues in my field, regard as clearly non-linear, even though it fully complies with the definition of a linear map from the vector space $\mathbb{R}_{&gt;0}$ to the vector space $\mathbb{R}$ (cf. Definition 4 below). A similar conflict arises analogously for the exponential function $\exp :\mathbb{R} \to \mathbb{R}_{&gt;0}$.  I do not want to initiate yet another discussion here, about what the right and what the wrong definition of linearity is! Rather, ...  ... I would like to compile a list of existing definitions, to get a better overview of the different uses of the term "linearity" across the different branches of mathematics and levels of education.    Let be begin with the following four, which are certainly far from constituting a complete list. What about bilinear or multilinear forms, linear morphisms and linear functors in category theory, linear metrics, or other concepts of linearity? I am looking forward to see your answers.  At school I was taught that     Definition 1:   A function $f$ is linear if it is of the form $f(x) = ax + b$.   Later I learned that $f(x) = ax + b$ is affine, rather than linear, because     Definition 2:   A function $f$ is linear if it is of the form $f(x) = ax$.   From real analysis and systems theory, I know the following     Definition 3:   A map $f$ is linear if         $f(x + y) = f(x) + f(y)$   $f(a \cdot x) = a \cdot f(x)$.      This definition also applies to the expected value in statistics, as        $\mathrm{E}(X + Y) = \mathrm{E}(X) + \mathrm{E}(Y)$   $\mathrm{E}(a \cdot X) = a \cdot \mathrm{E}(X)$.      In a linear algebra course, I learned for the first time that we must not forget to take into account that the vector-space operations of the domain and the codomain of a map $f$ may be dissimilar. In fact, if $(V, \oplus, \odot)$ and $(W, \boxplus, \boxdot)$ are two $\mathbb{K}$-vector spaces, then     Definition 4:   A map $f : V \to W$ is linear if         $f(x \oplus y) = f(x) \boxplus f(y)$   $f(a \odot x) = a \boxdot f(x)$.         Notice that I deliberately used distinct symbols for the operations in both vector spaces, to emphasize how this definition differs from Definition 3.   Correct me if I am wrong, but this definition should also apply to maps between two modules.    Updates: Why does ( exit 1 ) not exit the script? I have a script, that does not exit when I want it to.  An example script with the same error is:  #!/bin/bash  function bla() {     return 1 }  bla || ( echo '1' ; exit 1 )  echo '2'   I would assume to see the output:  :~$ ./test.sh 1 :~$   But I actually see:  :~$ ./test.sh 1 2 :~$   Does the () command chaining somehow create a scope? What is exit exiting out of, if not the script? Add increase/decrease tab indent buttons to the editor toolbar These should work by adding spaces or removing spaces from the beginning of the current line or every line between the start and end of a text selection (inclusive).  (edited this question to supplement ) Log out button illogical placement In the previous version the logout button is under your username, which it can be found by clicking the down arrow. However, in the new version, after a couple minutes of searching, it is under the "site-switcher" button:        This is really illogical since the logout button is usually under your username, including Google and Yahoo! services.  I suggest bringing back the  which will definitely benefit new users and even old users. Determine the size of a C++ array programmatically? This question was inspired by a similar question:   My question is a little different:  Is there any way to determine the size of a C++ array programmatically?  And if not, why?  Every function I've seen that takes an array also requires an integer parameter to give it the size.  But as the linked question pointed out, delete[] must know the size of the memory to be deallocated.  Consider this C++ code:  int* arr = new int[256]; printf("Size of arr: %d\n", sizeof(arr));   This prints "Size of arr: 4", which is just the size of the pointer.  It would be nice to have some function which prints 256, but I don't think one exists in C++.  (Again, part of the question is why it doesn't exist.)  Clarification: I know that if I declared the array on the stack instead of the heap (i.e. "int arr[256];") that the sizeof operator would return 1024 (array length * sizeof(int)). SQL Server default collation vs database with different collation - potential problems? I'm struggling with the design of new database that has to use a different collation (Y Collation) than the SQL Server Instance default collation (X Collation). I'm looking for potential problems.  Temp Tables by default will be created with X Collation so any joins on text data types will fail unless I create temp table with Y collations on columns.  What about SQL Server string functions: REPLACE, SUBSTRING, etc.? Will they always be returned in X collation? What about when I use REPLACE(...) COLLATE Y? Do you see any potential data loss or maybe any different problems? Help with packages in java - import does not work