I am getting this exception there Exception in thread &quot;AWT-EventQueue-0&quot; java.lang.NullPointerException: Cannot read field &quot;imeField1&quot; because &quot;controller.evidencijaController.view&quot; is null at controller.evidencijaController.spremiPodatke(evidencijaController.java:14) package controller;   import javax.swing.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement;  public class evidencijaController {     private static view.evidencijaView view;     private model.evidencijaModel model;     public static void spremiPodatke (String imeTurista, String prezimeTurista, String oibTurista, String mailTurista, String mobTurista) throws SQLException {         if(view.imeField1.getText().isEmpty()){             JOptionPane.showMessageDialog(view, &quot;The ID cannot be null!&quot;, &quot;Invalid info&quot;, JOptionPane.WARNING_MESSAGE);         }else{             Connection connection = DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/rezervacijalucica&quot;,&quot;root&quot;,&quot;&quot;);             Statement statement = connection.createStatement();             statement.executeUpdate(&quot;INSERT INTO turist(imeTurista, prezimeTurista, oibTurista, mailTurista, mobTurista) VALUES(&quot;+imeTurista+&quot;,&quot;+prezimeTurista+&quot;,&quot;+oibTurista+&quot;,&quot;+mailTurista+&quot;,&quot;+mobTurista+&quot;;)&quot;);         }     }```
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?
Get bytes from std::string in C++ I'm working in a C++ unmanaged project.  I need to know how can I take a string like this "some data to encrypt" and get a byte[] array which I'm gonna use as the source for Encrypt.  In C# I do    for (int i = 0; i &lt; text.Length; i++)     buffer[i] = (byte)text[i];   What I need to know is how to do the same but using unmanaged C++.  Thanks! How / can you connect Ethernet devices together without magnetics? How do you wire it up? What sorts of practical limitations are there on doing this?  To clarify, I'm not trying to connect two computers here. I'm thinking specifically of creating a small network of microcontrollers on a single board. Lets say the total length of a network segment is no longer than 6 inches. This would be for 10BaseT or at most 100BaseT. There are many visa applicants who are working as an unregistered freelancer (photographer, construction contractor, fashion designer, journalist etc ). Some of these freelancers make really handsome monthly income and don't really need to work as a full time employee. Most of them receive variable amount of payments (cash, cheques, demand drafts etc) When it comes to filling a visa application form (USA, UK, Schengen etc), there is always an employment section in all visa form, eg for Schengen visa employment form :    This is a very important factor to make an application really strong.  Questions:   1 Unregistered freelancers can just simply write their profession? what documents to produce along with the application?  2 Bank statements with variable methods of payments could convince the visa officer that these are all legitimate payments? What are "schlieren" in English? The German word for these patterns is "Schliere, pl. Schlieren", and apparently this word has entered the English language as a loanword (cf. article  in Wikipedia or entry  in OED). But the German loanword is probably not something most native speakers of English understand without the help of a dictionary, so what would you call, or how would you describe, the following patterns?  Concrete:    Air:    Oil on water:    Coffee and milk:    Paint:    Smoke:    Rock:    Marbled paper:    And so on.    "Waves" is not applicable, because waves are vertical undulations of the surface, while these are a pattern on, or inside, the surface level, with no amplitude.  "Striæ" does not really fit either, because those refer more to the parallel layers, than to the curly forms. Is it possible to insert arguments into functions when they're used like Function@ or //Function? Number reference headline I try to number the header of my references. I succeeded to add the number to the table of contents, but I can't get it to work for the header.  To add the number to the toc I used:  \addcontentsline{toc}{section} \protect\numberline{\thesection}References}   If I try the same for \refname, I get 5References without space.   \renewcommand{\refname}{\protect\numberline{\thesection References}}   When I put the references title outside the curly brackets, it's shown in a new line. What am I missing here? The full bibliography call looks like this:  \renewcommand{\refname}{\protect\numberline{\thesection References}} \addtocounter{section}{1} \cleardoublepage \phantomsection \addcontentsline{toc}{section}{\protect\numberline{\thesection}References} \bibliographystyle{apacite} \bibliography{bachelor}   EDIT 1:  As @TeXnician stated, a tilde would solve the problem. It is not very elegant, though, as I have to use approximatly three of them to get the same space as in the other headlines.   \renewcommand{\refname}{\protect\numberline{\thesection~~~References}}   EDIT 2: @Werner suggested a shorter solution, but it throws multiple errors, when I try to integrate it into my .tex file. Here's a short reproducable example which replicates the errors.  \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage[margin=1.1in]{geometry} \usepackage{listings} \usepackage{apacite} \usepackage{natbib}  \begin{filecontents}{mybib.bib}  @Article{draxler2010sample,     author    = {Draxler, Clemens},     title     = {Sample size determination for Rasch model tests},     journal   = {Psychometrika},     year      = {2010},     volume    = {75},     number    = {4},     pages     = {708--724},     publisher = {Springer}, }  \end{filecontents}   \begin{document}  \tableofcontents      \section{First Chapter}  \citep{draxler2010sample}  \let\oldsection\section% Store \section in \oldsection \renewcommand{\section}[2]{\oldsection{#2}}% Update \section to gobble * \bibliography{mybib} \bibliographystyle{apacite}  \appendix  \section{R Code}  \subsection{Greedings Function}  \begin{lstlisting}     print("Hello World") \end{lstlisting}  \end{document} Coloring a black and white PDF graphic I have a graphic in PDF format (originally converted from an SVG) that is monochromatic (black on white). Is it possible using TikZ or PSTricks but not (Illustrator or Inkscape) to include this image in a different color?  Example:    While it lasts (there seems to be no long term way to host a pdf), you can .  Edit: Simple was perhaps a bit of a misnomer - the pdfs are cropped and monochromatic, but to intricate to redraw on my own. The above example is a character from a font (which I can recolor), but it gives a good example of what shapes I am talking about. When I press the power button a dialog opens, but I want to shutdown the system without receiving "Do you really really want to shutdown?". How can I choose a direct shutdown action on a pressed power button?   I had the same problem with the 11.04 version, but I don't remember the solution and yesterday I upgraded to Ubuntu 11.10. Is there a term for grammatical mistakes as a result of trying too hard? Show inbox updates in the page title Background  Recently  was implemented. With this feature the amount of questions with new activity is shown in parenthesis at the beginning of the page title, e.g.     (2) Meta Stack Overflow   means that MSO has two questions with new activity since the user last viewed it.   this feature is unrelated to inbox updates. Here is an example to illustrate this:    Even though there are two inbox messages in this screenshot this is not reflected by the page title. The page title is currently only sensitive to questions with new activity.  Suggestion  I suggest that the page title also reflects inbox updates. For the screenshot above this would mean that the page title shows that there are two inbox updates and two questions with new activity.  I am not sure what format is best for showing this. For chat * in the page title is used to show that there are messages directed at you which is similar in meaning to inbox updates. However, * if is placed after the number in parenthesis to denote inbox updates there might be confusion as there is no connection between the number in parenthesis and * like in chat. Thus, one might prefer another format such as one of the following (all are meant to reflect the status of the screenshot above):      * (2) Meta Stack Overflow     2* (2) Meta Stack Overflow     [2] (2) Meta Stack Overflow     2i 2q  Meta Stack Overflow     (2/2)  Meta Stack Overflow     (2|2)  Meta Stack Overflow    For the alternatives without an explicit hint of which number refers to what it might be best to place the number for questions with new activity first as it will in most cases be greater. This will to a greater degree avoid combinations such as "(0/2)" which may be confused zero of two.  An advantage of the suggested feature is that if the user has a browser tab with a Stack Exchange site then they will be instantly notified of inbox updates. They do not need to focus a tab with a Stack Exchange site to know if there are inbox updates, they merely have to check the relevant page titles among their tabs.  A disadvantage of the suggested feature is that it might be experienced as verbose. I suggest that it is implemented such that it is as unobtrusive as possible while still being informative. Think of a situation where a user has   one Meta Stack Overflow tab with two inbox updates relating to Meta Stack Overflow and two questions with new activity, and one Super User tab with one inbox updates relating to Super User and three questions with new activity.   Then the sum of the inbox notification in the page titles should be local to sites and not global. The page titles for the tabs above should be something like the following pair:      2i 2q  Meta Stack Overflow     1i 3q  Super User How to set parameters for Describe() function? I developed one tool  in arcgis using python code, in the process i used Describe(feature class) function to know the coordinate system of input feature class. I got success while compiling code, But i couldn't get how to set parameters for this function in tool(arcgis 10.0) designing.  I tried parameters as follow  Display  name:input feature class Data type : coordinate system. Type   : optional Direction : input.   My problem is  while i'm selecting input feature class, i didn't get coordinate system of that feature class.  Please Suggest.. Solving equation involving Euler's totient function Given $m\in\mathbb{N}$, is there a general way to solve the equation \begin{equation} \varphi(n)=m \end{equation} where $\varphi$ is the Euler's totient function? For example, I want to solve for all the $n$'s such that $\varphi(n)=4$. Is there any way to solve it that are also applicable to many (if not general) cases? I have two given names and one surname. Is it a problem if I omit the surname from my ticket? I have two names as my given name in the passport and I typically just use this as my first and last name. However, my passport has a surname too which I almost never use. Due to this, I mistakenly provided my given name as first and last name.   As per the passport,  Surname : AAAA Given name(s) : BBBB CCCC   In the ticket, First name : BBBB Last name : CCCC  The credit card I've used to make this booking has my name as BBBB CCCC.  Will this create a problem at the travel time?  Update : the airline says that they can't update the name in the ticket. They are saying that since they have made a remark of the passport details boarding will not be a problem but I might face problems at immigration. Do they check name details in itenerary to exactly match passport at the time of immigration? Is that true in your experience?  Update : Travelled without any problem, neither at boarding gate, immigration nor after arrival at border police control. so I am trying to show that $f(x)$ divides $g(x)$ for all polynomials $g(x)$ satisfying that $g(A)=0$ where $f(x)$ is the minimal polynomial of a square matrix $A$.  I know from my professor that $f(x)$ is the minimal polynomial of $A$ so $f(A)=0$ so then $g(A)=0$. Therefore, $f(x)$ divides $g(x)$, i.e. $g(x)=f(x)h(x)$ where $h(x)$ is some other polynomial.  My prof told us to solve this question we need to let $b(x)=gcd((f(x),g(x))$ and by using Bezout's Identity, we need to show that $b(A)=0$. I am just having a little trouble trying to prove this. I know that this identity says:     For two polynomials $f_1(x)$ and $f_2(x)$, there exist polynomials   $g_1(x)$ and $g_2(x)$ such that $g_1(x)f_1(x) + g_2(x)f_2(x) = &gt; gcd(f_1(x), f_2(x))$.   And the uniqueness of minimal polynomial theorem is:     For a square matrix $A$, if $f_1(A) = f_2(A) = 0$ for two polynomials   $f_1(x)$ and $f_2(x)$, then $g(A) = 0$ for $g(x) = gcd(f_1(x), &gt; f_2(x))$. So the minimal polynomial of $A$ is unique up to a scalar.   So since $f(x)$ is already the minimal polynomial, I know that the $deg(b(x))=deg(f(x))$. I know how to prove the Bezout identity using the Euclidean algorithm, I'm just not exactly sure how I would show all of this using the notation he gave us of $b(x)=gcd((f(x),g(x))$. Any help at all would be appreciated. Nested Radical of Ramanujan I think I have sort of a proof of the following nested radical expression due to Ramanujan for $x\ge 0$.     $$\large x+1=\sqrt{1+x\sqrt{1+(x+1)\sqrt{1+(x+2)\sqrt{1+\cdots}}}}$$ for $ x\ge -1$   I just want to know if my proof is okay or there is a flaw, and if there is one I request to give some suggestions to eliminate them. Thank you. The proof is the following:  Proof: Let us define $$ a_n(x)=\underbrace{\sqrt{1+x\sqrt{1+(x+1)\sqrt{1+(x+2)\sqrt{1+\cdots}}}}}_{n \ \mbox{terms}}$$ for $x\ge 0$ so that $$ a_1(x)=\sqrt{1+x},\ a_2(x)=\sqrt{1+x\sqrt{1+(x+1)}},\ a_3(x)=\cdots$$    and so on. Since $x\ge 0$ each one of the $a_n$ is defined (I am taking only the positive square root). Also, we note that $$a_{n+1}^2(x)=1+xa_{n}(x+1)$$  Now, we note that $\{a_n(x)\}$ is an increasing sequence and that $$a_n(x)&lt;x+1$$ $\forall n\ge 1$, this is easy to prove by induction as below:  For $n=1$, $a_1(x)=\sqrt{1+x}&lt;1+x$ since $x\ge 0\Rightarrow 1+x\ge 1$. SO it is true for $n=1$. Similarly, the truth can be proved for $n&gt;1$.  Then $a_n(x)$ converges to $$l(x)=\sup_{n}a_n(x)\le x+1$$ Now I make the following claim:  Claim: $l(x)=x+1\quad \forall i\ge 0$  Proof: Fix $x$. Let $l(x)&lt;x+1$. Then, $l(x)=x+1-\epsilon$ for some $\epsilon&gt;0$. Now, I claim that there must be a $n$ such that $$x+1-a_n(x)&lt;\epsilon$$, and if that is true then $$a_n(x)&gt;x+1-\epsilon=l(x)$$ which is a contradiction since $$l(x)=\sup_{n}a_n(x)$$ and then it implies that $$l(x)=x+1$$ To prove my claim it requires $$x+1-a_n(x) &lt;  \epsilon$$ Now, \begin{align} x+1-a_n(x) = &amp; x+1-\sqrt{1+xa_{n-1}(x+1)} \\ \ =&amp; \frac{(x+1)^2-({1+xa_{n-1}(x+1)})}{x+1+\sqrt{1+xa_{n-1}(x+1)} } \\ \ =&amp; x\frac{(x+1)+1-a_{n-1}(x+1)}{x+1+\sqrt{1+xa_{n-1}(x+1)} } \\ \ &lt;&amp; \frac{x}{x+2}((x+1)+1-a_{n-1}(x+1))\\ \ &lt;&amp; \frac{x}{x+2}\cdot\frac{x+1}{x+3}((x+2)+1-a_{n-2}(x+2))\\ \ &lt;&amp; \frac{x}{x+n-1}\cdot \frac{x+1}{x+n} ((x+n-1)+1-a_{1}(x+n-1))\\ \ &lt;&amp; \frac{x}{x+n-1}\cdot \frac{x+1}{x+n}(x+n-\sqrt{x+n})\\ \ &lt;&amp; \frac{x(x+1)}{x+n-1} \end{align}  Now, if one is able to find $n$ such that $$\frac{x(x+1)}{x+n-1}&lt;\epsilon \Rightarrow x&lt; \frac{-(1-\epsilon)+\sqrt{(1-\epsilon)^2+4\epsilon(n-1)}}{2}$$ then we're done.   Now from the upper bound it seems that there always exists some $n$ that satisfies this requirement. Hence the claim is proved. In a photoelectric effect we remove electrons from a metal using high energy photons, the work function is the minimal energy required for this effect.  My question is why doesnt the work fucntion depended on time? The more electrons we take out from the metal, the more ionized it becomes (if we remove a lot of negative charge, it will turn positive), and as a result we would expect to need more energy for this effect (the possitive charge of the metal would make it harder to remove the remaining electrons).  Why does the work function remains constant no matter how much electrons we take out? What are badges? How do users get badges? How can users get tag badges? Can badges be lost/revoked/taken away after they are awarded? If so, how and when? How can I suggest a new badge?   For more information, see &quot;&quot; and the  in the . AWK: Nested Conditional Subset of Rows I have a pretty specific question, and have been able to find lots on conditional subsetting using awk but none that lends enough explicit code for me to generalize to my situation. I have a file 'keys' and a file 'features'. The 'keys' table contains two variables, KEY and GROUP, toy example below.      KEY        GROUP     ---        -----     1          GROUP0     2          GROUP0     3          GROUP1     4          GROUP1     5          GROUP2     6          GROUP2     The file 'features' contains a list of features of widgets like so      ID          FEATURE      VALUE     --          -------      -----     A           num_user     10     A           KEY          4     B           num_user     2     B           KEY          2     B           battery      Large     C           num_user     10     C           KEY          15     D           num_user     2     D           KEY          2     D           battery      Small     E           num_user     2     E           KEY          7     E           battery      Small   I am trying to select all rows for an ID which has a value of 'KEY' that is in the 'KEY' column of 'keys' for a hardcoded list of 'GROUP' values. The desired result is      ID          FEATURE      VALUE     --          -------      -----     A           num_user     10     A           KEY          4     B           num_user     2     B           KEY          2     B           battery      Large     D           num_user     2     D           KEY          2     D           battery      Small   Any ideas? How to check a large backpack? When travelling on airlines based in the US with a large backpack, I prefer to carry the bag onto the plane as part of my hand baggage allowance.  Most foreign flag carriers, however, have a significantly more restrictive hand baggage allowance.  I was caught off guard by this one time on New Zealand airlines and received my backpack with multiple broken straps and clips.  I managed to repair it, and I'm still using the same pack, but I would like to avoid so many broken parts in the future.    Once, when flying Alitalia (flight was actually booked through Delta) I carried plastic wrap to the airport, and wrapped the entire bag in it before handing it over to the airline.  @jpatokal recommends putting it into a giant, heavy-duty garbage bag in his answer to .     What are the pros and cons of using plastic wrap or a garbage bag?   Can anyone recommend any other, more effective techniques? Killing form on $\mathfrak{sp}(2n)$ I have the same question as  from a long time ago. Is there an easy way to see that the Killing form on $\mathfrak{sp}(2n)$ is $\kappa(x,y) = (4n+2) \mathrm{tr}(xy)$?  For example, the Killing form for $\mathfrak{sl}(n)$ can be found from the easier to calculate case of $\mathfrak{gl}(n)$ using the decomposition $$\mathfrak{gl}(n) = \mathfrak{sl}(n) \oplus \mathbb{C}.$$ I don't know a similar argument for $\mathfrak{sp}(2n)$ though.