Browsing 7239 questions and answers with Jon Skeet
This is one problem: index *= k; Suppose k is 7. You want to remove 14, 21, 28 etc. Instead, you're removing 7*7, then 7*7*7, then 7*7*7*7 etc. You're also changing the value of index, which means you'll skip later numbers. You want... more 12/2/2013 4:58:48 PM
Basically, the combination of those two errors means you can't use multi-catch - i.e. catch (Exception1 | Exception2 | Exception3 e) - when you're going to run the code on a version of Java earlier than Java 7. Either update the JRE... more 12/2/2013 4:56:24 PM
You're doing two things: Fetching the position Setting it It's entirely possible that each of those performs a direct interaction with the underlying Win32 APIs, whereas normally you can read a fair amount of data without having to... more 12/2/2013 4:51:11 PM
Well it sounds like you just want a collection of possible values, and an index between 0 and 3 inclusive: int[] values = { 724329, 714385, 715440, 696492 }; Random random = new Random(); // Ideally initialize once for the entire app int... more 12/2/2013 4:38:35 PM
Yes, with the same seed you should get the same sequence of numbers. The algorithm is specified in the documentation: An instance of this class is used to generate a stream of pseudorandom numbers. The class uses a 48-bit seed, which... more 12/2/2013 9:13:52 AM
All resources are being used and a new thread asks for resources that are not available. Since it waits inside the synchronized function, the other threads that are using the resources are not able to free the resources as the... more 12/2/2013 6:53:15 AM
Java strings cache their hash codes - so if the hash codes are equal, the strings are very likely to be equal. A full equality check could take much longer, if the strings are the same length and only differ near the very end. (The... more 12/2/2013 6:50:39 AM
You seem to be confused about whether you actually want an array or not. You're parsing a single value, but trying to assign that int to c which is an array variable. You don't really need one, as you only need to remember the current... more 12/1/2013 11:44:33 AM
I suspect you're using the wrong file name. The documentation for GetLastWriteTime specifies: If the file described in the path parameter does not exist, this method returns 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated... more 11/30/2013 11:08:52 PM
Yes, getParameterTypes() returns an array - one element for each parameter. Just use: for (Class<?> clazz : classMethods[i].getParameterTypes()) { System.out.println("Parameter type " + clazz.getName()); } (Adjust the output... more 11/30/2013 11:07:17 PM