Browsing 7239 questions and answers with Jon Skeet

What's the point of package modifiers?

I don't understand package modifiers (not annotations) like this: public package foo; public class Bar { } Do they have any meaning?
Jon Skeet
people
quotationmark

The only type of package modifier in the JLS is an annotation. From JLS 7.4.1: PackageDeclaration: {PackageModifier} package Identifier {. Identifier} ; PackageModifier: Annotation So public package foo; is invalid... more 9/3/2014 12:31:26 PM

people

Java 8 method reference unhandled exception

I'm working on project with Java 8 and found one situation which I can't understand. I have code like this: void deleteEntity(Node node) throws SomeException { for...
Jon Skeet
people
quotationmark

If you look at the Consumer<T> interface, the accept method (which is what your method reference would effectively be using) isn't declared to throw any checked exceptions - therefore you can't use a method reference which is... more 9/3/2014 11:47:13 AM

people

Will GetHashCode method return different result for an object between different AppDomain?

According to this Eric blog, Rule: Consumers of GetHashCode cannot rely upon it being stable over time or across appdomains. Suppose you have a Customer object that has a bunch...
Jon Skeet
people
quotationmark

I am saving the hash of the product properties object in database for change tracking. Don't do that. That's pretty much the definition of requiring the hash code to be stable over time. AppDomains are pretty irrelevant to this, to be... more 9/3/2014 11:36:17 AM

people

Passing double pointer in c as a pass by value

/*i am doing in main function*/ int main(void) { //allocating memory double** p = malloc(ROWS * sizeof(double*)); int i, j; for (i = 0; i < ROWS; i++) p[i] =...
Jon Skeet
people
quotationmark

You passed the pointer by value - but that's just a pointer. That says where the memory containing the individual values is. Your make5 function doesn't actually change the value of the parameter (d) at all - that would be something... more 9/3/2014 6:07:46 AM

people

Add .jars in alternative folder

I am new to Eclipse and Java, and I know that .jar files I need to add into libs derectory so that compiler could recognize them. How I can add .jars not only in libs folder but...
Jon Skeet
people
quotationmark

It's easiest if you have the jar files visible in the package explorer to start with, i.e. within your project directory. At that point, you can just right-click on the jar file, go to the "Build path" section of the context menu, then... more 9/3/2014 5:51:48 AM

people

LINQ to SQL error on .Join()

I'm trying to query a database and join two tables. I've never used Join() this way and I'm getting an error on the second Join(): var adjustments = data.Inventory_ARCHIVEs ...
Jon Skeet
people
quotationmark

I suspect this is the problem - it's at least one problem: .Join(data.BQItems, x => new { x.a.UPCCode, x.b.Location }, y => new { y.UPC_Code, y.Location }, ...) You're trying to join using... more 9/2/2014 7:11:19 PM

people

Explaining confusing conditional string format

An ex-coworker wrote this: String.Format("{0:#;;} {1:records;no records;record}", rows, rows - 1); //Rows is a integer value I read articles like these Code Project - Custom...
Jon Skeet
people
quotationmark

This is a custom numeric format string, basically - but a pretty odd one, to be honest. In fact, it's two of them: #;; records;no records;record In each case, you've got three sections, due to having two section separators (the... more 9/2/2014 4:39:33 PM

people

Enhanced for loop empty check optimization

I know with java one shouldn't bother with things like this but I just can't resist, which is the faster?: ArrayList <Integer> keke = new ArrayList(); ArrayList...
Jon Skeet
people
quotationmark

The enhanced for loop does an empty check before it starts to do anything right? No, I wouldn't expect it to. I'd expect it to just create the iterator, which then won't find anything. That's what JLS 14.14.2 describes, anyway: ... more 9/2/2014 2:19:25 PM

people

Convert Local TimeZone to PST in Windows Phone

I need to Convert my Local TimeZone to PST in Windows Phone, do we have an API to do it? If not then what is the best practice here? Note the phone can be in any timezone based on...
Jon Skeet
people
quotationmark

Assuming you mean Pacific Time, you can use my Noda Time project for this, assuming that DateTime works correctly in terms of the the local conversion. // Initial conversion using BCL classes DateTime local = ...; DateTime utc =... more 9/2/2014 6:23:50 AM

people

Building WALA on osx "the import java.lang.invoke cannot be resolved"

I am attempting to compile WALA on OSX and getting a confusing error that it cannot find java.lang.invoke.CallSite. The odd thing is that I can write a simple project that...
Jon Skeet
people
quotationmark

The java.lang.invoke package was introduced in Java 7. As your mvn version command shows, Maven is using Java 6: Java version: 1.6.0_65, vendor: Apple Inc. Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home You... more 9/1/2014 9:19:34 PM

people