Reverse a string in Java

You can use this: Or, for versions earlier than JDK 1.5, use java.util.StringBuffer instead of StringBuilder — they have the same API. Thanks commentators for pointing out that StringBuilder is preferred nowadays when there is no concurrency concern.

strdup() – what does it do in C?

Exactly what it sounds like, assuming you’re used to the abbreviated way in which C and UNIX assigns words, it duplicates strings 🙂 Keeping in mind it’s actually not part of the ISO C standard itself(a) (it’s a POSIX thing), it’s effectively doing the same as the following code: In other words: It tries to allocate enough memory … Read more

Convert list to array in Java [duplicate]

Either: or: Note that this works only for arrays of reference types. For arrays of primitive types, use the traditional way: Update: It is recommended now to use list.toArray(new Foo[0]);, not list.toArray(new Foo[list.size()]);. From JetBrains Intellij Idea inspection: There are two styles to convert a collection to an array: either using a pre-sized array (like … Read more

How do I install pip on macOS or OS X?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. I spent most of the day yesterday searching for a clear answer for installing pip (package manager for Python). I can’t find a good solution. How do I install it?

What do ++ and *+ mean?

++ From What is double plus in regular expressions? That’s a Possessive Quantifier. It basically means that if the regex engine fails matching later, it will not go back and try to undo the matches it made here. In most cases, it allows the engine to fail much faster, and can give you some control … Read more

Unexplained crashes related to ntdll.dll

I have an application that I’ve written that crashes intermittently, but I’m unable to capture an exception at the application layer. I always get an entry in the event log but doesn’t give me much info: As you can see, I get this: Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll. I’m not sure what that is or how … Read more

After command npm start “Missing script:start” error

To download and install all modules in the node_modules/ folder, you need to use install and not start. As start is not predefined by npm, you need to define a custom script for it, if you want to use the comment. So install is the default command to download and install all modules, depending on you package.json: