How to initialize List object in Java?

If you check the API for List you’ll notice it says: Being an interface means it cannot be instantiated (no new List() is possible). If you check that link, you’ll find some classes that implement List: All Known Implementing Classes: AbstractList, AbstractSequentialList, ArrayList, AttributeList, CopyOnWriteArrayList, LinkedList, RoleList, RoleUnresolvedList, Stack, Vector Some of those can be instantiated (the ones that are not defined as abstract class). Use their links to know more about them, I.E: to … Read more

OSError – Errno 13 Permission denied

You need to change the directory permission so that web server process can change the directory. To change ownership of the directory, use chown:chown -R user-id:group-id /path/to/the/directory To see which user own the web server process (change httpd accordingly):ps aux | grep httpd | grep -v grep ORps -efl | grep httpd | grep -v grep

Read whole ASCII file into C++ std::string

There are a couple of possibilities. One I like uses a stringstream as a go-between: Now the contents of “file.txt” are available in a string as buffer.str(). Another possibility (though I certainly don’t like it as well) is much more like your original: Officially, this isn’t required to work under the C++98 or 03 standard (string … Read more

What condition does while(true) test? When is it true and false?

When is while(true) true, and when is it false? It’s always true, it’s never false. Some people use while(true) loops and then use break to exit them when a certain condition is true, but it’s generally quite sloppy practice and not recommended. Without the use of break, return, System.exit(), or some other such mechanism, it will keep looping forever.

How to update Xcode from command line

What you are actually using is the command to install the Xcode command line tools – xcode-select –install. Hence the error message you got – the tools are already installed. The command you need to update Xcode is softwareupdate command [args …]. You can use softwareupdate –list to see what’s available and then softwareupdate –install -a to install all updates or softwareupdate … Read more

glm rotate usage in Opengl

You need to multiply your Model matrix. Because that is where model position, scaling and rotation should be (that’s why it’s called the model matrix). All you need to do is (see here) Note that to convert from degrees to radians, use glm::radians(degrees) That takes the Model matrix and applies rotation on top of all the operations that are … Read more

Why is there no String.Empty in Java?

String.EMPTY is 12 characters, and “” is two, and they would both be referencing exactly the same instance in memory at runtime. I’m not entirely sure why String.EMPTY would save on compile time, in fact I think it would be the latter. Especially considering Strings are immutable, it’s not like you can first get an empty String, and perform some operations … Read more