java java-8 hashmap

Top new questions this week:

Why does this code, written backwards, print “Hello World!”

Here is some code that I found on the Internet: class M‮{public static void main(String[]a‭){System.out.print(new char[] {‘H’,’e’,’l’,’l’,’o’,’ ‘,’W’,’o’,’r’,’l’,’d’,’!’});}} This code prints …

java unicode right-to-left
asked by Shashwat 111 votes
answered by Davis Broda 118 votes

Why explicitly throw a NullPointerException rather than letting it happen naturally?

When reading JDK source code, I find it common that the author will check the parameters if they are null and then throw new NullPointerException() manually. Why do they do it? I think there’s no need …

java nullpointerexception hashmap
asked by LiJiaming 103 votes
answered by shmosel 159 votes

Why can a const member function modify a static data member?

In the following program, modifying a static data member from a const function is working fine: class A { public: static int a; // static data member void set() const { a = …

c++ function c++11 static const
asked by rsp 56 votes
answered by Bathsheba 68 votes
Stack Overflow Jobs puts developers first.
No recruiter spam or fake listings
Browse Jobs

TreeSet is showing wrong output

While working with a tree set, I found very peculiar behavior. As per my understanding this program should print two identical lines: public class TestSet { static void test(String… args) { …

java treeset
asked by Show Stopper 32 votes
answered by VGR 30 votes

HashMap Java 8 implementation

As per the following link document: Java HashMap Implementation I’m confused with the implementation of HashMap (or rather, an enhancement in HashMap). My queries are: Firstly static final int …

java java-8 hashmap
asked by Hasnain Ali Bohra 30 votes
answered by Michael 86 votes

All versions of GCC struggle with a template that has the default type in a definition

I wasted countless hours to pinpoint an issue with gcc. I wanted to test our code base with another compiler to look for more warnings that Clang might have missed. I was shocked that practically half …

c++ c++11 templates gcc
asked by GreenScape 29 votes
answered by GreenScape 24 votes

Why is `(foo) = “bar”` legal in JavaScript?

In Node.js’s REPL (tested in SpiderMonkey as well) the sequence var foo = null; (foo) = “bar”; is valid, with foo subsequently equal to “bar” as opposed to null. This seems counterintuitive …

javascript ecma
asked by TERMtm 29 votes
answered by Bergi 16 votes

Greatest hits from previous weeks:

How do I get PHP errors to display?

I have checked my PHP ini file and display errors is set and also error reporting is E_ALL. I have restarted my Apache web server. I have even put these lines at the top of my script, and it doesn’t …

php error-reporting
asked by Abs 853 votes
answered by Fancy John 1725 votes

Sort a Python dictionary by value

I have a dictionary of values read from two fields in a database: a string field and a numeric field. The string field is unique, so that is the key of the dictionary. I can sort on the keys, but how …

python sorting dictionary
asked by Gern Blanston 2206 votes
answered by Devin Jeanpierre2652 votes

Can you answer these?

HTTP 502 from one instance of an Azure Web App

We suddenly began experiencing HTTP 502 errors (The specified CGI application encountered an error and the server terminated the process) from one of the instances of our web app. I was able to …

azure azure-web-sites azure-diagnosticsazure-app-service-plans azure-app-service-envrmnt
asked by davenewza 7 votes

No such method error while using robospice-retrofit and

In our project we are using , Which require okhttp: 1.6.0 And getstream java client io.getstream.client:stream-repo-okhttp:1.2.2′, Which require …

android retrofit2 okhttp robospice getstream-io
asked by Sanyasirao Mopada 5 votes

Apply attribute directive on component in Angular 4

I have created img-pop component which has @Input() bind property src. I have created authSrc directive which has @HostBinding() property src. @Component({ selector: ‘img-pop’, template: `<img …

angular angular2-directives angular-componentsangular2-hostbinding