Browsing 7239 questions and answers with Jon Skeet
It doesn't look like there's any such method or constructor at the moment, but it's dead easy to write a helper method: public static Color newColorWithAlpha(Color original, int alpha) { return new Color(color.getRed(),... more 3/31/2015 10:12:39 PM
You're setting the month number to be -1, i.e. "December of the year before". You want to add -1 month: today.add(Calendar.MONTH, -1); I'd strongly recommend using Joda Time or Java 8's java.time package if you possibly can though -... more 3/31/2015 3:56:47 PM
The Method.invoke method takes an Object[] parameter which corresponds to the arguments you want to provide. As you've got a single parameter which is of type Object[], you need to wrap that in another Object[]. For... more 3/31/2015 3:15:47 PM
No, you won't get an exception for that. If you call notifyAll when nothing is waiting, nothing happens basically. It's not an error condition. more 3/31/2015 11:22:14 AM
You've declared sum inside your loop - so you're starting again on each iteration. You want: int sum = 0; for(int i = 0; i < al.size(); i++) { sum += al.get(i); } System.out.println("The sum is: " + sum); Note that: I've changed... more 3/30/2015 1:45:14 PM
Firstly, if you're looking to use lots of connections to a single site, you may well want to tweak the process configuration to allow that - otherwise you'll find you get a bottleneck on the WebClient. See the <connectionManagement>... more 3/30/2015 1:18:13 PM
The problem is that the first call to nextLine() is reading the empty "line" between the end of "5" (read for m) and the line break. Personally, I would either stop using Scanner entirely (in favour of BufferedReader) - there's a huge... more 3/30/2015 11:34:46 AM
even if the syn.manipulate() method is locked so I'm assuming the task cannot get to calling getI() That's the mistake you're making, I believe. Just because one method is synchronized doesn't implicitly mean that anything else is... more 3/30/2015 11:25:35 AM
i thought class Secretaire can access Personne'members, and not the opposite ? That would be true in C#, but not in Java. In Java, all the code within the same top-level class can access all the private members of all the classes... more 3/29/2015 1:22:13 PM
You're creating a new - and empty - set each time the code runs: HashSet<Circle> circles = new HashSet<>(); if (!circles.isEmpty()) { // You'll never get in here... } If you want to maintain the same set across calls,... more 3/28/2015 10:03:02 AM