Browsing 7239 questions and answers with Jon Skeet
To do this I have used a picture box, who's data is converted into bytes and then into a string to send over the socket connection to the server. This all works OK. Given the code you've shown, I'd suggest it probably doesn't. In... more 1/14/2015 11:39:42 AM
Expressions are evaluated left to right - always, regardless of grouping. So it's equivalent to: a = 5; int lhs = a; // 5 int rhs = (a = a + 5); // Increments a by 5 (i.e. a=10), and rhs=10 b = lhs + rhs; // 15 So after this has... more 1/14/2015 7:33:03 AM
Well your second code wouldn't even compile. But you could just write: bool isEven = a % 2 == 0; or bool isEven = (a & 1) == 0; Why use either the conditional operator or an if statement? In general, when you have something... more 1/14/2015 6:58:05 AM
No - that's usually what it does, but accessors can perform whatever calculation you want. Fundamentally, a property is meant to provide access to logical state of a value - but that logical state doesn't have to translate to a single... more 1/14/2015 6:49:01 AM
It's easy to get the breed: public class Dog { private final String name; private final String breed; protected Dog(String name) { // Default to using the class name this(name, getClass().getSimpleName()); ... more 1/13/2015 7:02:27 PM
In the below shall I replace INSTANCE with A singleObj = new A();? You don't. You use: EasySingleton instance = EasySingleton.INSTANCE; You write the singleton just like a normal class, with whatever methods you want etc - but no... more 1/13/2015 6:55:16 PM
You're actually already building an expression tree which has the right type at execution time (if you just don't try to call the method, and print out the type of the object that the value of lambda refers to). However, the compile-time... more 1/13/2015 6:48:54 PM
Is there a way to tell the garbage collector, that he is allowed to remove object that are only referenced by this List, and nowhere else? Sort of. You want to make it a List<WeakReference<T>> or something similar. See the... more 1/13/2015 6:11:41 PM
Firstly, I'd question the use of separate threads at all here. If you want one thing to happen after another, just use a single thread. However, it's easy to wait until one thread has finished - just use join: Thread t1 = new... more 1/13/2015 1:39:54 PM
It sounds like your city() method should return the array of cities, which you can then pass to the printCity() method: public String[] city() { ... return cityInArr; } public void printCity(String[] cities) { ... } And in... more 1/13/2015 1:21:12 PM