Browsing 7239 questions and answers with Jon Skeet

Tasks & Exceptions Issue

I am new to tasks and I hope you can help me out with this. Here is code: Task tast = null; try { tast = new Task(() => { ... }); tast.Start(); if (tast...
Jon Skeet
people
quotationmark

You're calling Task.Wait() - which will throw an exception if the task is faulted. If you don't call Task.Wait(), you won't get the exception in your thread... but of course you won't spot when it's finished, either. There are various ways... more 3/20/2014 3:17:00 PM

people

Is it possible to debug Lambdas in Java 8

I just started playing with Java 8 Lambdas and I noticed that I can't debug them in the NetBeans IDE. If I try to attach a breakpoint to the following code I get a variable...
Jon Skeet
people
quotationmark

It works for me in Eclipse. For example: public class Foo { private static final Runnable r1 = () -> { System.out.println("r1a"); System.out.println("r1b"); }; public static void main(String[] args) { ... more 3/20/2014 12:00:24 PM

people

Error writing text on image

I try to write a text on my image: private Bitmap drawText() { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.test); Canvas canvas...
Jon Skeet
people
quotationmark

Disclaimer: I'm not an Android developer. I've never written code like this. It's just my interpretation of the documentation... I suspect you actually want to set the bitmap to draw onto much earlier, and then draw the other bitmap into... more 3/20/2014 11:49:03 AM

people

Put character in SimpleDateFormat

I want to validate the code of Date. Input come from Textbox where user enters it. and in code it will get calender's date instance and match it. I want to put character in that...
Jon Skeet
people
quotationmark

You can't, basically. You need three separate SimpleDateFormat objects: new SimpleDateFormat("dd'st' MMM, yyyy") new SimpleDateFormat("dd'nd' MMM, yyyy") new SimpleDateFormat("dd'th' MMM, yyyy") ... then try parsing with each of them.... more 3/20/2014 10:47:02 AM

people

Java AES not decrypting Arabic

I'm working on Eclipse to encrypt and decrypt a string. I'm using the following functions: private final static String ALGORITHM = "AES"; public static String cipher(String...
Jon Skeet
people
quotationmark

There are three separate transformations here: Unencrypted text to unencrypted bytes Unencrypted bytes to encrypted bytes Encrypted bytes to hex ... and the reverse, of course. I suspect the problem is in the first step. Currently... more 3/20/2014 10:39:31 AM

people

CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference? in c#

I am working on c# and am beginner. I am under a situation that I am creating Huffman tree where I calculate the frequency of the symbols in a binary file (I mean number of times...
Jon Skeet
people
quotationmark

Let's look at a massively reduced version of this: public class Huffman<K> { public class Node<T> where T : K { } public Node<T> front, rear; } What is the type of front and rear here? It refers to T,... more 3/20/2014 10:12:08 AM

people

Static members and interfaces

I just went through a handful of SO questions on this topic and found out that this is (currently?) not possible to define static members in interfaces or make static methods...
Jon Skeet
people
quotationmark

Basically the C# type system isn't geared up for this. It's not often a problem, but when it does come up it's a pain :( Some options you might want to think about, all of which start off by removing the existing property: Create a... more 3/20/2014 7:09:15 AM

people

UTF 16 reserved codepoints

Why UTF-16 have a reserved range in UCS Database? UTF-16 is just a way to represent character scalar value using one or two unsigned 16-bits, the layout of these values shouldn't...
Jon Skeet
people
quotationmark

Your proposed scheme is less efficient than the current surrogate pair scheme, which is one problem. Currently, only 0xD800-0xDFFF (2048 code units) are "out of bounds" as normal characters, leaving 63488 code units mapping to single... more 3/19/2014 6:34:12 PM

people

jodatime truncates remaining months when interval is greater than a year

I am trying to check if a given interval is greater than 12 months using the following code: public void testMonths() throws Exception { DateTimeFormatter format =...
Jon Skeet
people
quotationmark

The problem is your text pattern. "mm" means "minutes" not "months". If you change your pattern to "yyyy-MM" you'll find it works fine. As a guiding principle the first thing I would do in a situation like this is try to isolate this to... more 3/19/2014 2:19:08 PM

people

Where comments are stored and how to extract them?

Suppose we have the following code: /// <summary> /// Test class comment /// </summary> public class Test { /// <summary> /// Method comment ///...
Jon Skeet
people
quotationmark

Where does the C# compiler store comments in assembly? It doesn't. If IntelliSence can use comments, I also want. In that case, you need to turn on XML documentation generation in your build. (Assuming you're using Visual... more 3/19/2014 2:06:31 PM

people