Browsing 7239 questions and answers with Jon Skeet

How to get Unicode of smiley in scala

I am getting smilies as an input from the user. val emojis="😃😜😍" I want its unicode to store in DataBase. in my console it is printing like this 😃😜😍 may be question...
Jon Skeet
people
quotationmark

I think you're looking for U+263A. The best way to represent this in source code is with a Unicode escape sequence: val smiley = "\u263a"; You then need to check that: Your database is able to store it (check the type of your field,... more 7/26/2014 7:32:20 AM

people

why same class file in eclipse not overwriting and showing error type already defined

created a "java" class in eclipse, when try to use same class name in same package again it showing error "type already defined". when write program in notepad and running in...
Jon Skeet
people
quotationmark

EDIT: Okay, through comments I think we've actually got to the bottom of the problem. The situation is: Compiling under Windows There are two classes in the same file, with the same name except for case The command-line compiler doesn't... more 7/25/2014 5:47:39 PM

people

How to pass an instance of of a class from within that class

I am wondering about something which can be achieved in c++ but I want to do it in C#. How can I pass a "pointer" to a class, from within the class that contains the code,...
Jon Skeet
people
quotationmark

All you need to do is move the initialization expression out of the field declaration and into a constructor: public class MainClass { public string Something; public SubClassA A; public SubClassB B; public MainClass() ... more 7/25/2014 2:45:09 PM

people

Which C# double literal is not exactly representable as double?

Wikipedia says: For example, the decimal number 0.1 is not representable in binary floating-point of any finite precision However, in C# string s =...
Jon Skeet
people
quotationmark

I have a small source file which print the exact value stored in a double. Code at the end of the answer, just in case the link goes away. Basically, it fetches the exact bits of the double, and goes from there. It's not pretty or... more 7/25/2014 12:21:22 PM

people

Updating XML file in C#

I'm trying to update my XML file. But my parsing code is returning null as a result. This is my code: StreamResourceInfo xml = Application.GetResourceStream(new...
Jon Skeet
people
quotationmark

This is the problem: doc.Elements("Category") That's looking for root elements called Category (the root element is the only direct child element of the XDocument). You... more 7/25/2014 11:55:40 AM

people

why & operator returns Int32 instead of bool?

byte op1 = 20; sbyte op2 = 30; var result = op1 & op2; I know that & operator returns bool, but I cunfused now. why equals result 20? Why is result Int32?
Jon Skeet
people
quotationmark

I know that & operator returns bool That's only true when the operands are bool as well. The & operator is either logical or bitwise, depending on its operands. From the documentation: Binary & operators are predefined... more 7/25/2014 10:46:21 AM

people

Modify a list while it is being iterating

While I was testing my own answer to get the output for this question, I got the following output for the given list content: // Add some strings into the list list.add("Item...
Jon Skeet
people
quotationmark

Fundamentally, you're modifying a list in one thread while iterating over it in another, and the list implementation you're using does not support that. The ArrayList iterator implementation appears to only detect invalid modicifications... more 7/25/2014 8:00:39 AM

people

Utility method to convert Boolean into boolean and handle null in Java

Is there a utility method in Java which converts Boolean into boolean and automatically handles null reference to Boolean as false?
Jon Skeet
people
quotationmark

How about: boolean x = Boolean.TRUE.equals(value); ? That's a single expression, which will only evaluate to true if value is non-null and a true-representing Boolean reference. more 7/25/2014 7:40:02 AM

people

Using Java HttpUrlConnection to download a PDF file,buffer set to 1024 bytes Wrong,but 8 is ok

I want to use java(httpurlconnection class) to download a pdf file,but have some thing puzzle,the core code is: BufferedInputStream inputStream = new...
Jon Skeet
people
quotationmark

You're unconditionally writing out the whole of the buffer on each iteration. You should only write out as many bytes as you've just read: int bytesRead; while((bytesRead = inputStream.read(infoBytes)) != -1){ output.write(infoBytes,... more 7/25/2014 7:33:28 AM

people

Does JIT convert the binary code of IL into binary machine code?

This is regarding .NET. Code (high-level: c#,vb.net - human understandable) is compiled in VS and dll/exe is generated This is called IL (this is also more or less human...
Jon Skeet
people
quotationmark

Code (high-level: c#,vb.net - human understandable) is compiled in VS and dll/exe is generated This is called IL (this is also more or less human understandable). You need to differentiate between the binary form of IL, and the... more 7/25/2014 7:16:50 AM

people