I'm getting this error when I run my code to see if a Binary Tree is full: The error I'm getting from my code is: Exception in thread &quot;main&quot; java.lang.NullPointerException: **Cannot invoke  &quot;BinaryTree$Node.isAFullTree()&quot; because &quot;this.right&quot; is null** at BinaryTree$Node.isAFullTree(BinaryTree.java:97) at BinaryTree$Node.isAFullTree(BinaryTree.java:97) at BinaryTree$Node.isAFullTree(BinaryTree.java:97) at BinaryTree.isAFullTree(BinaryTree.java:209) at Main.main(Main.java:30)  public boolean isAFullTree ()     if(left == null &amp;&amp; right != null           {                   return false;           }             if(left != null &amp;&amp; right == null           {                   return false;           }             return true  &amp;&amp; right.isAFullTree() &amp;&amp; left.isAFullTree(); // This line throws the exception           } }
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?
How to extract the last inserted row in SQL Server? When an insert statement is executed one or more rows is inserted into the table, is there any way to extract the last inserted row in SQL Server? How to prove that if $a\equiv b \pmod{kn}$ then $a^k\equiv b^k \pmod{k^2n}$ Which pronoun to refer to "person"? It? He or She? They? "When he found his seat on the plane, Sam recognized the person who was sitting in the seat next to his. It? She? was a woman he knew."  Which is more common/natural? Isn't 'it' more correct – grammatically speaking – than 'she', since 'a person' can be a 'he' or a 'she', and obviously you cannot use the singular 'they' here? The Public Platform team is continuing to work towards  and we’re here today to announce a new onboarding experience for the review queues. In the  (), we learned that each queues’ instructions could be easily misinterpreted and additional information was difficult to find. Without proper guidance or context, new reviewers would contribute inconsistent reviews and risk having their review privileges suspended. With this release, our goals were to 1) better highlight the review privilege and 2) provide upfront instruction and guidance for successful reviewing. New privilege announcements Community moderation is a significant aspect of Stack Overflow and the Stack Exchange sites. We want users to be aware and familiar with this newly earned privilege, but also celebrate the opportunity to contribute to the community in a unique way.  Many users were discovering the review queues by chance. Once the privilege is earned, a new review queue icon with a red alert would appear in the top-right part of the navigation. We are adding a popover to bring more attention to this easy-to-miss icon. We will also be adding notices for when users earn access to other, higher reputation queues. Additionally, new reviewers will also receive an email notification about the newly earned privilege. They will only get the email if they earn the privilege and don't perform a review within 24 hours (anyone who doesn't want to receive email notifications like this can visit their  and turn off &quot;Tips and Reminders&quot;). We are also showing a popover to users who earned access to review queues in the past, but have never done a review or haven't reviewed in the last 30 days. This popover is only appearing for the next 90 days. The goal is to engage users who may not have interacted with the queues since we made  and . Welcome banner  If a reviewer clicks “Learn more” on the on-page popover or goes to the review queue home page (/review), they’ll be greeted with an onboarding message with general information about the review queues. Informational modals  Queue-specific modals will appear upon page load as you visit each queue. They summarize and highlight important aspects and tips about reviewing in a particular queue. This information can be revisited at any time by clicking “Learn more” under the page header. Feedback As always, please leave your feedback and any bugs you may discover related to this release below this post. We will be monitoring this post for the next few weeks (May 4, 2021). After May 4th, please report any further issues as new questions. Variable importance from GLMNET Edit:  Of course my real code doesn't look exactly like this. I tried to write semi-pseudo code to make it more clear of whay I wanted to do.  Looks like it just messed things up instead.  So, what I actually would like to do is this:  Method&lt;Interface1&gt;(); Method&lt;Interface2&gt;(); Method&lt;Interface3&gt;(); ...   Well ... I thought that maybe I could turn it into a loop using reflection. So the question is: How how do I do it. I have very shallow knowledge of reflection. So code examples would be great.  The scenario looks like this:  public void Method&lt;T&gt;() where T : class {} public void AnotherMethod() {     Assembly assembly = Assembly.GetExecutingAssembly();      var interfaces = from i in assembly.GetTypes()     where i.Namespace == "MyNamespace.Interface" // only interfaces stored here     select i;      foreach(var i in interfaces)     {         Method&lt;i&gt;(); // Get compile error here!     }       Original post:  Hi!  I'm trying to loop through all interfaces in a namespace and send them as arguments to a generic method like this:  public void Method&lt;T&gt;() where T : class {} public void AnotherMethod() {     Assembly assembly = Assembly.GetExecutingAssembly();      var interfaces = from i in assembly.GetTypes()     where i.Namespace == "MyNamespace.Interface" // only interfaces stored here     select i;      foreach(var interface in interfaces)     {         Method&lt;interface&gt;(); // Get compile error here!     } }   The error I get is "Type name expected, but local variable name found". If I try  ...     foreach(var interface in interfaces)     {         Method&lt;interface.MakeGenericType()&gt;(); // Still get compile error here!     } }   I get "Cannot apply operator '&lt;' to operands of type 'method group' and 'System.Type'" Any idea on how to get around this problem? Prove $\det(kA)=k^n\det A$ How do HttpOnly cookies work with AJAX requests? JavaScript needs access to cookies if AJAX is used on a site with access restrictions based on cookies. Will HttpOnly cookies work on an AJAX site?   Edit: Microsoft created a way to prevent XSS attacks by disallowing JavaScript access to cookies if HttpOnly is specified. FireFox later adopted this. So my question is: If you are using AJAX on a site, like StackOverflow, are Http-Only cookies an option?  Edit 2: Question 2. If the purpose of HttpOnly is to prevent JavaScript access to cookies, and you can still retrieve the cookies via JavaScript through the XmlHttpRequest Object, what is the point of HttpOnly?  Edit 3: Here is a quote from Wikipedia:     When the browser receives such a cookie, it is supposed to use it as usual in the following HTTP exchanges, but not to make it visible to client-side scripts.[32] The HttpOnly flag is not part of any standard, and is not implemented in all browsers. Note that there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest. [33].   I understand that document.cookie is blocked when you use HttpOnly. But it seems that you can still read cookie values in the XMLHttpRequest object, allowing for XSS. How does HttpOnly make you any safer than? By making cookies essentially read only?   In your example, I cannot write to your document.cookie, but I can still steal your cookie and post it to my domain using the XMLHttpRequest object.  &lt;script type="text/javascript"&gt;     var req = null;     try { req = new XMLHttpRequest(); } catch(e) {}     if (!req) try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}     if (!req) try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}     req.open('GET', 'http://stackoverflow.com/', false);     req.send(null);     alert(req.getAllResponseHeaders()); &lt;/script&gt;   Edit 4: Sorry, I meant that you could send the XMLHttpRequest to the StackOverflow domain, and then save the result of getAllResponseHeaders() to a string, regex out the cookie, and then post that to an external domain. It appears that Wikipedia and ha.ckers concur with me on this one, but I would love be re-educated...  Final Edit: Ahh, apparently both sites are wrong, this is actually a . IE6 &amp; 7 are actually the only browsers that currently fully support HttpOnly.  To reiterate everything I've learned:   HttpOnly restricts all access to document.cookie in IE7 &amp; and FireFox (not sure about other browsers) HttpOnly removes cookie information from the response headers in XMLHttpObject.getAllResponseHeaders() in IE7. XMLHttpObjects may only be submitted to the domain they originated from, so there is no cross-domain posting of the cookies.   edit: This information is likely no longer up to date. Initial connection to SQL Server Connection Is Slow. Why? How to replace text between quotation marks with something from another file? I have the following kind of text: $OU = 'or'; $DINHEIRO_CAIXA = 'Cash balance'; $PAGINA = 'Page'; $DE = 'from'; $ENVIAR = 'Send'; $PRINCIPAL = 'Main';  I've already got all the text within the single quotation marks using cat arquivo | grep -oP &quot;'[^']+'&quot; | tr -d &quot;'&quot; This extracted text was then translated to Portuguese, but now I don't know how to replace the original text between single quotation marks with the translated text, I was looking for something like $OU = 'ou'; $DINHEIRO_CAIXA = 'Dinheiro em caixa'; $PAGINA = 'Pagina'; $DE = 'de'; $ENVIAR = 'enviar'; $PRINCIPAL = 'Principal';  I've tried using grep -F to replace the file itself, but it failed miserably because the pattern didn't match since I don't have the quotation marks on the new file, is there a way to do this? Possible Duplicate:             Well, I remembered this after having Algebra II a year ago, is it possible that this is a valid proof that $1 = -1$?  $$ 1 = \sqrt{1} = \sqrt{-1\cdot-1} = \sqrt{-1} \cdot \sqrt{-1} = i \cdot i = i^2 = -1 $$  $$ \therefore 1 = -1 $$  So is this actually fully valid? Or can it be disproved? Why is my document pdf generated by pdflatex looks different from the one generated by latex+dvips+ps2pdf ? From the code below, i have tow different papers switch to the tow cited commands above :  \documentclass[10pt,a4paper]{article} \usepackage[utf8]{inputenc} \usepackage[francais]{babel} \usepackage[T1]{fontenc} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{graphicx} \usepackage{lipsum} \author{M ROUAN SERIK} \title{Article with \LaTeXe} \fontfamily{cmr} \begin{document} \maketitle \section{Titled section} \lipsum \end{document}   Here's my pdffonts for the tow pdfs : Pdflatex:    name                   type     encoding  emb sub uni object ID   ------------------------------- ---------------- --- --- --- ---------   AMTRHA+SFRM1728        Type 1    Custom   yes yes no       4  0   DPTCLU+SFRM1200        Type 1    Custom   yes yes no       5  0   JVZRKA+CMMI12          Type 1    Builtin  yes yes no       6  0   UEWNID+SFBX1440        Type 1    Custom   yes yes no       7  0   FOVERL+SFRM1000        Type 1    Custom   yes yes no       8  0     latex+dvips+ps2pdf      name                                 type              encoding         emb sub uni object ID   ------------------------------------ ----------------- ---------------- --- --- --- ---------   WVMUEH+SFRM1000                      Type 1C           WinAnsi          yes yes no        16  0   ZHRBNN+SFBX1440                      Type 1C           WinAnsi          yes yes no      14  0   IMJWCD+CMMI12                        Type 1C           Custom           yes yes no      12  0   MDMSVR+SFRM1200                      Type 1C           WinAnsi          yes yes no      10  0   TWHNMT+SFRM1728                      Type 1C           WinAnsi          yes yes no       8  0 On which Canary island is it possible to sleep on the beach? We are planning a two-night trip to the Canary Islands. The cheapest options include Lanzarote and Las Palmas for flights. Travel dates are last week of November, so I guess weather should be okay. I have never been to these islands. I'd like to sleep on the beach in a tent or mattresses. Is that possible, safety, legality, and weather? It would also be nice to know how populated with tourists the islands are. No CUDA and GPU option We have an Always On "cluster" that consists of 2 servers (there will be more), so one is PRIMARY and other(s) is(are) SECONDARY. The idea was to dedicate SECONDARY as a readonly replica, so it would be a somewhat search-server.  I do know how to set ConnectionString in the C# so it will use SECONDARY replica - just add ApplicationIntent=ReadOnly.  But I don't understand how to address the SECONDARY from stored procedure if I'm using distributed query. Is there a way to set some parameters to the query (like WITH statements or something), so query would use only replica and not the PRIMARY node?  The thing is, obviously from the start server1 is PRIMARY and server2 is SECONDARY, but when server1 fails then server2 is PRIMARY and server1 will be SECONDARY after it get fixed. So I cannot just use the static server2's name.  So far I've managed to get current replica's server name as a variable and use it in EXEC:  -- find first available replica DECLARE @replicaServer nvarchar(50)  SELECT TOP 1     @replicaServer = RCS.replica_server_name FROM     sys.availability_groups_cluster AS AGC     INNER JOIN sys.dm_hadr_availability_replica_cluster_states AS RCS           ON RCS.group_id = AGC.group_id     INNER JOIN sys.dm_hadr_availability_replica_states AS ARS           ON ARS.replica_id = RCS.replica_id     INNER JOIN sys.availability_group_listeners AS AGL           ON AGL.group_id = ARS.group_id WHERE ARS.role_desc = 'SECONDARY'       AND connected_state = 1  -- and query it DECLARE @cmd nvarchar(MAX) = 'SELECT * FROM [' + @replicaServer + '].[somebase].[someschema].[sometable]' EXEC (@cmd)   But that's a shame, I guess. "This edit would have to be a suggested edit" / edit button grayed out A couple of times recently when I attempted to edit a post while reviewing it from the "First Posts" queue, I received the following message when I tried to submit the form:  This edit would have to be a suggested edit. (x)   This is a rather cryptic message, considering that edits made from a review are suggested edits, subject to the same peer review process. There was no indication of how the edit would have to be submitted differently, much less why. I searched both help and meta for more information about this message, but came up empty.  The first time it happened, after I cancelled out I saw that someone else had just edited the post, so I thought maybe that's why I couldn't submit an edit from the review (and wondered why, if that's the case, the error message didn't just say that instead of telling me something that doesn't make any sense - that the edit I'm trying to suggest can't be submitted because it would have to be a suggested edit). However, the second time I received this message (last night, for this question: ), there was no other edit. So, I clicked the No action needed button and tried to edit the post outside the review process, only to discover that the edit link was grayed out.   I see several explanations of possible causes for graying out the edit link here: . However, there was no tooltip when I hovered over the disabled link, and the edit queue was in the single digits.  A few minutes later, I noticed that the edit link was no longer grayed out, so I edited the post and my edit was accepted.   My best hypothesis based on my experience with the error so far and the explanations I've read here at meta is that someone submitted a suggested edit while I was reviewing the post, which (a) caused me to get the cryptic error message and (b) caused the edit link to be grayed out when I accessed the post the normal way. Then a few minutes later, the suggested edit was rejected, opening up the question for new edit suggestions.  Rather than speculating about it and trying to determine the answer scientifically, it would be helpful if someone could give me the answer (as Seinfeld fans might put it, "Why don't you just tell me why I can't edit the post?"). It would be even more helpful if the error message itself provided the explanation, or if the message were defined somewhere in the help pages. But, at the very least, hopefully there will soon be an answer on meta to enlighten people who scratch their chins over this in the future. :) Should a button become lighter or darker on hover? We're having a discussion in the office about whether a button should become lighter or darker when a user hovers over it.   Here are some examples from the field:  Apple "Buy Now" button (Second is hover, third is depressed) -     Twitter Bootstrap -    (Unselected)   (Hover)  Github homepage - github.com      The button on FogBugz homepage goes from yellow to slightly lighter yellow. The buttons on Optimizely and Visual Website Optimizer hardly change.  Amazon's "Buy Now" button doesn't do anything when you hover over it (besides change to a pointer cursor). The colored buttons in Google's new interface (see Gmail or Calendar) go slightly darker when you hover over them.  Finally here is our button:    Should your button become lighter or darker when you hover over it? What else should you consider? Does anyone have data on whether the hover effect matters for conversions? If $\gcd(a,b)=1$, then $\gcd(a+b,a^2 -ab+b^2)=1$ or $3$. I’ve had this issue for months but in the last couple of days it’s got very very bad.  When my phone runs out of battery it needs like 2–3 days to turn back on. At the beginning of this problem the phone would need about 1h. Every time when my phone goes off again the time to switching on goes up.  What does this all look like? Well, when my phone died I put it on the charger, then the logo appears and goes off. When it goes off, a black screen pops out with a little white line on in it, then it turns on back to Apple logo. It keeps doing this until it turns on which is 1 or 2 even now 3 days.  I tried to restore it and also update it but nothing happens, literally nothing happened. How do I create tools with multiple properties?