Browsing 15836 questions and answers with Jon Skeet

Creating a table within a dataset in BigQuery programmatically

Is it possible to create a table within a dataset in BigQuery using the API in Java? I know it's possible with bq mk --schema <fileName> -t...
Jon Skeet
people
quotationmark

I haven't used the Java BigQuery library personally1, but it looks like you should call BigQuery.create(TableInfo, TableOptions[]. That documentation has this example code - assuming you already have an instance of a BigQuery interface... more 8/5/2017 8:19:59 PM

people

Convert.ToDouble in c# not giving right answer when accessing redis database

Im trying to convert a long string of numbers into a double in order to use that as an index to a redis database (redis requires a double) but the conversion isnt correct so the...
Jon Skeet
people
quotationmark

I cant understand why, its a WHOLE NUMBER, no fractional part to create error so why it cant do it? Because it still only has 64 bits of information to play with, 52 of which are used for the mantissa, 11 of which are used for the... more 8/5/2017 7:21:02 PM

people

Hashmap Key: String, Value: Boolean. How do I test the value within an if statement?

/ public void getFinishedBooks(HashMap<String, Boolean> library) { if (library.size() < 1) { System.out.println("No books in Library"); } else { for (String books...
Jon Skeet
people
quotationmark

Rather than getting the key set, I'd get the entry set - that means you can iterate over the key/value pairs, rather than having to look up each key again. For example, to print all the books with a true value: for (Map.Entry<String,... more 8/5/2017 5:15:49 PM

people

Create delegate with reference to method in DLL

I have DLL with some methods. I load it in runtime and I want to create delegate to method that is located in DLL. DLL: public static Point Play(int[,] foo, int bar, int baz) {...
Jon Skeet
people
quotationmark

You'd need to find the type containing the method first, then use Delegate.CreateDelegate: Type type = ass.GetType("NameOfTypeContainingMethod"); PlayDel del = (PlayDel) Delegate.CreateDelegate(typeof(PlayDel), type,... more 8/5/2017 5:12:29 PM

people

Changing System Date and Time Using DateTimePicker via C#?

I'm trying to change the time but when I try to change the time to 00:00 it becomes 08:00 instead? Is it considering my timezone which is UTC + 8? using System; using...
Jon Skeet
people
quotationmark

Yes, it's precisely because of the time zone issue. From the docs for SetSystemTime: Sets the current system time and date. The system time is expressed in Coordinated Universal Time (UTC). So if you're trying to change it to a... more 8/5/2017 1:30:32 PM

people

Unexpected character "

For some reason I am getting an error message Unexpected character " however it doesn't actually underline any of my code in read. I tried cleaning and rebuilding it but that...
Jon Skeet
people
quotationmark

You've got two "odd" characters within FindElement - U+200C (zero-width non-joiner) and U+200B (zero-width space) between the first "e" and the "m". The same characters occur in "Click" between the "l" and the "i". Just delete and retype... more 8/4/2017 8:52:59 AM

people

Unreachable objects on the stack cannot be garbage collected

Against my expectations, the following program import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.List; public class StackTest { public static void...
Jon Skeet
people
quotationmark

The problem is that you still have a list iterator on the stack, and that list iterator has a reference to the original list. That's keeping the list alive just as if you'd never set objects to null. An iterator has to keep a reference to... more 8/3/2017 7:05:59 AM

people

Why does char not autobox to Character in Java?

Working to improve ESAPI's encoding methods to handle non-BMP characters, I encountered unexpected behavior. It was interesting, to say the least... This unit test: public void...
Jon Skeet
people
quotationmark

Java can box char to Character perfectly easily. This will work fine: Character c = in; However, overload resolution occurs in multiple phases for the sake of backwards compatibility. In early versions of Java (before autoboxing) your... more 8/2/2017 6:25:16 AM

people

The error: System.Reflection.TargetParameterCountException was unhandled by user code

The code looks as following: public static class ResLocator { public static string Resolve(Type assemblyObjectType, string resourceName) { MethodInfo...
Jon Skeet
people
quotationmark

Here, you're specifying the types of the parameters for the method you're looking for: new[] { typeof(Assembly), typeof(string), typeof(bool), typeof(bool), typeof(ScriptManager) } Here, you're specifying the argument values to... more 8/1/2017 2:19:10 PM

people

TreeMap put is not working as expected

class Point{ int x, y, l; Point(int x, int y, int l){ this.x =x; this.y =y; this.l=l; } @Override public int hashCode() { ...
Jon Skeet
people
quotationmark

Your TreeMap is comparing Point values by the l part (whatever that's meant to be). That's what this part of your code does: new TreeMap<>((p1, p2)-> p1.l-p2.l); The two points you've created have the same l value (0) so... more 8/1/2017 12:42:20 PM

people