Browsing 7239 questions and answers with Jon Skeet
You don't need to worry about the base - if you're dealing with algorithmic complexity, it doesn't matter which base you're in, because the difference is just a constant factor. Fundamentally, you just need to know that log n means that... more 8/29/2014 4:44:35 PM
You don't need to return anything (assuming you change the method signature to return void) - the elements of the array have been swapped in-place. For example: int[] array = { 3, 5, 4 }; swap(array, 0, 2); System.out.println(array[0]);... more 8/28/2014 8:09:27 PM
It says: Non-static method 'getX1()' cannot be referenced from a static context Right - that's got nothing to do with creating an array, or anything like that. The problem is that getX1() is an instance method - it needs to operate... more 8/28/2014 6:00:58 PM
No, that's not the way Java works. You can't use variable names determined at execution time. Instead of having 52 separate variables, you should have an array or a collection: private final Random random = new Random(); private final... more 8/28/2014 5:57:25 PM
addActionListener has a return type of void - so you can't write: panelThird.add(new JTextField(...).addActionListener(...)); Instead, you need: JTextField field = new... more 8/28/2014 4:55:48 PM
Well, you've got a query... but for some reason you're calling ExecuteNonQuery. You should be specifying ExecuteScalar in order to fetch a single value. You can then cast the result to int: return (int) command.ExecuteScalar(); I assume... more 8/28/2014 2:39:20 PM
Fundamentally I think you've missed what the assignment operator does. This statement: b = doSomething(); changes the value of b to whatever the doSomething() method returns. It doesn't depend on the existing value of b at all. So... more 8/28/2014 1:46:23 PM
The reason I ask is that I know that Strings are immutable, which suggests that there is a more efficient alternative, am I right? Nope. You're calling readLine multiple times, that's going to give you a different string reference... more 8/28/2014 12:09:03 PM
A java.util.Date isn't in any particular time zone - it's just an instant in time, which will have different local times around the world. Internally, it's a number of milliseconds since the Unix epoch, but frankly it could be a different... more 8/28/2014 8:56:07 AM
You can use explicit interface implementation, if you really only want the method to be available via an expression of the interface type: void Interface1.Show() { throw new NotImplementedException(); } You can't remove the... more 8/28/2014 6:40:06 AM