Browsing 7239 questions and answers with Jon Skeet
In the case you've given, there's no difference. Typically this is used to disambiguate between instance variables and local variables or parameters. For example: public A(String a) { this.a = a; // Assign value from parameter to... more 1/25/2014 10:44:17 AM
Separating your code into different projects (each of which will create a separate assembly) has various benefits: It makes the structure of your code clear. For example, it can separate your storage layer from your business logic, and... more 1/25/2014 10:09:28 AM
New answer just using TimeSpan The problem is that : isn't recognized within the custom TimeSpan format specifier. You need to escape it. At that point, the culture really isn't relevant at all, so I'd specify the invariant culture,... more 1/25/2014 8:19:35 AM
Just call toString() - Interval (or rather AbstractInterval) overrides toString with a readable format. For example: Instant start = new Instant(0L); Instant end = new Instant(1390596587000L); Interval interval = new Interval(start,... more 1/24/2014 8:50:10 PM
Just count how many elements match your filter first, then create the array, then populate it. It means you'll need to go through the array twice, but there are no really nice alternatives unless you want to end up creating multiple... more 1/24/2014 8:04:37 PM
Why doesn't the JVM recognize that a System.exit(0) will not allow any other code to execute, but complains about unreachable statements if a return will not allow code to be executed? It's not the JVM - it's the compiler. And the... more 1/24/2014 3:26:35 PM
This is a difference between String.Substring(int) in .NET, and String.substring(int, int) in Java. In .NET, the second parameter is the length of the substring you're trying to take. In Java, the second parameter is the exclusive end... more 1/24/2014 11:08:23 AM
Assuming you're concerned about the list modification rather than general structure, yes - there's a better way. Rather than using remove then add, use List.set(index, element): String oldVal =... more 1/24/2014 10:40:10 AM
It's not really clear what you're trying to do, but you don't return parameters, and I don't think overloading is really the problem here. To take overloading out of the situation, you can always change the methods to have different names... more 1/24/2014 9:44:16 AM
I suspect you want something like: for (int i = 0; i < users.size(); i++) { // Access the user by position in the list User user = users.get(i); // Now print the username for that specific user ... more 1/24/2014 8:42:39 AM