Browsing 7239 questions and answers with Jon Skeet
You basically need to simplify your loop: on each iteration of the loop, ask for both the subject name and the grade, then create one object to store them both: for (int i = 0; i < gradeArray.length; i++) { ... more 11/28/2014 10:29:21 AM
You can just check whether Calendar.getInstance(Locale) returns a GregorianCalendar: for (Locale locale : Calendar.getAvailableLocales()) { if (locale.getCountry().length() > 0 && Calendar.getInstance(locale) instanceof... more 11/28/2014 9:13:22 AM
The "class" constraint is really a "reference type" constraint - it doesn't specifically mean classes. (It works with delegate types too.) From the MSDN page on generic type constraints: The type argument must be a reference type; this... more 11/27/2014 11:45:20 PM
It's a value from the ChronoUnit enum, implementing TemporalUnit - your code can be written as: Duration.of(3, ChronoUnit.SECONDS); I'm not sure what you mean by "it's not evaluating to anything" - it's specifying what units you want to... more 11/27/2014 11:42:53 PM
a is not an object. It's a variable. The type of the variable is A. The type of the object that the value of the variable refers to at execution time is B. The compiler resolves everything against the compile-time type of the expressions... more 11/27/2014 6:45:20 PM
My question is how can I reword the processing section to not cause this error. Well, there are two situations that the compiler is concerned about: If the input is invalid, you're already changing lblConvertedTemperature.Text... more 11/27/2014 5:47:14 PM
The Joda Time DateTime and LocalDate constructors which take Object have documentation including: The String formats are described by ISODateTimeFormat.dateTimeParser(). The text you're providing is not in an ISO format. Instead,... more 11/27/2014 3:42:55 PM
When you call a method or constructor, you pass arguments - values - you're not declaring the parameters like you do when you declare the method or constructor. So it should be something like: GraphicsConfiguration gc = ...; // Whatever... more 11/27/2014 3:32:56 PM
I would like to unit test this class. Therefor I need to mock the "IsSavable" method. It should always return "true". No, that's a non-sequitur. You can just create a subclass which does what you want: // Within your test code class... more 11/27/2014 3:24:36 PM
It sounds like you just want: String[] bits = s.split(":"); if (bits.length() != 2) { // Throw an exception or whatever you want } JSONObject json = new JSONObject(); json.put(bits[0], bits[1]); more 11/27/2014 1:35:20 PM