Browsing 7239 questions and answers with Jon Skeet
do/while is precisely suitable when you always want to execute at least once, but you want to check whether or not to keep going at the end of the loop instead of at the start. You can easily emulate it with a while loop, but sometimes... more 5/13/2014 5:02:26 PM
The problem here isn't StringBuffer - it's simply the encoding used by System.out. You'd find the exact same behaviour when printing the string directly, without using a StringBuffer. StringBuffer (and its more modern, non-thread-safe... more 5/13/2014 2:10:29 PM
You should use ImageIcon(URL) and get the resource URL from the classloader, e.g. ImageIcon info = new ImageIcon(IMC.class.getResource("/images/exclamaçao mario3.jpg")); (I'd avoid using non-ASCII characters in the filenames, by the... more 5/13/2014 10:42:21 AM
The Task<bool> returned from your Test method will become faulted. If you await that task (or call Wait() on it) then the exception will be rethrown at that point. If you choose to ignore the faulted state of the task, then yes,... more 5/13/2014 9:57:14 AM
Your code is broken in the way it's looping - you're stopping on the very first iteration, either reporting success or failure. You should be continuing to loop until you find something or run out of items to iterate over. I would change... more 5/13/2014 9:48:19 AM
Well, it means you only evaluate size() once instead of once per iteration. Theoretically, that could be a performance win - it's just possible that computing the size is actually expensive. (For example, you could have a linked list... more 5/13/2014 9:31:55 AM
On concatenating 2 String constants in s2 doesn't result in a new String object That's true when it's performed with the string concatenation operator - but that's not what you're doing here. You're manually calling String.concat, so... more 5/13/2014 8:00:59 AM
The JAVA_HOME environment variable is irrelevant to how Eclipse will run code, as far as I'm aware. Likewise the compiler settings you've shown for a project don't affect how code is run. Instead, you need to look at the Run Configuration... more 5/13/2014 7:50:43 AM
This line is the problem: object[] attrs = typeof(T).GetCustomAttributes(true); You're calling GetCustomAttributes on Type - not on the type that you're actually interested in. You want: object[] attrs =... more 5/13/2014 6:00:31 AM
Just cast rFoobar to IFoobar<T>: T foobar = ((IFoobar<T>)rFoobar).CreateFoobar(); That way you're calling a method that returns T rather than just Foobar. As Rotem suggests, changing the method in Foobar to use explicit... more 5/12/2014 10:09:00 PM