Browsing 7239 questions and answers with Jon Skeet
It looks like this has nothing to do with arrays, but everything to do with your general syntax. You're using { } for attribute arguments instead of ( ), and your attribute doesn't have public properties, which are required for named... more 1/5/2018 7:30:24 AM
You've been experimenting when serializing the data, but the conversion is happening when you deserialize the JSON to start with. That's where you need to disable DateParseHandling. Here's the change you need: var settings = new... more 1/4/2018 6:34:05 PM
Not by using a method reference, no - but it's easy to do with a lambda instead: entities.sort(Comparator.comparing(entity -> entity.getSubEntity().getAmount())); Fundamentally there's nothing magical about Comparator.comparing - it... more 1/4/2018 12:21:08 PM
It's not the declaration that's failing - it's the attempt to initialize the variable using an expression which can throw a checked exception. You should declare the field, then initialize it in a constructor. That constructor will have... more 1/4/2018 11:25:25 AM
Think of the array element as if it were an instance field of the array. Imagine your array were: public class FourElementStringArray { public string element0; public string element1; public string element2; public string... more 1/3/2018 10:04:58 AM
Not without throwing an exception, no. Bear in mind that in many cases the calling method will be non-void - in that case, what value would you expect it to return? The use case you're describing does sound like it would be better handled... more 1/3/2018 9:13:12 AM
You're checking the value before you assign a new value to it. You need to assign the value from nextInt(), then check whether it's in range. For example: if (input.hasNextInt()) { int candidate = input.nextInt(); if (candidate... more 1/2/2018 9:15:26 PM
You're ordering by your string representation which starts with the month. It looks like you're actually only interested in distinct dates though - grouping and then discarding everything other than the key is equivalent to just... more 1/2/2018 12:19:53 PM
You need to load the file as a resource. You can use Class.getResourceAsStream or ClassLoader.getResourceAsStream; each will give return an InputStream for the resource. Once you've got an InputStream, wrap it in an InputStreamReader... more 12/29/2017 8:50:05 PM
Firstly, each parameter element only has a single name, so just use Element for that. Next, use name as the element you're looking for, not Name. Finally, you're looking for a value of CO, not an element called CO. So you'd have... more 12/25/2017 2:06:40 PM