Browsing 7239 questions and answers with Jon Skeet

Rest call should return objects and internal fields in same sequence

I'm using rest call for some testing. UI testing. After calling rest call and I want it to return fields in object in same order all the time. What can I do for that? There was...
Jon Skeet
people
quotationmark

happy and social should not change their order. Is their a way? Well, that's just a JSON object. It's rare (IME) that the order should matter - and that doesn't look like it's what actually causes the failure you're seeing. I would... more 4/23/2015 4:11:07 PM

people

String truncated while transferring from Client to Server Java

I'm trying to send a detail of client system to server system but the server isn't receiving everthing. It stops printing once it has reached the first line. someone help me get...
Jon Skeet
people
quotationmark

You're calling writeObject multiple times on the same ObjectOutputStream - but in the reading code, you're only calling readObject once. You'll need to loop in the reading code, e.g. while (true) { String message = (String)... more 4/23/2015 11:34:41 AM

people

Cannot find symbol error in cmd but not in IDE

I'm trying to compile the following code (one of two files I need to complete this homework) but I'm getting 2 errors in cmd. This is what cmd throws at...
Jon Skeet
people
quotationmark

What am I doing wrong here? Not building CarRental, or not telling the compiler where to find the class if you have already compiled it. The IDE is probably assuming you want to build everything, so that's fine. We don't know how... more 4/23/2015 10:46:59 AM

people

I cant get out of my while loop

The following program i wrote for a class activity to prompt the user for a infinite amount of test marks between 0 - 100 and when a user enters a mark outside that range it...
Jon Skeet
people
quotationmark

When the user enters "-1" its should stop the program and then print out the average of those marks. Well if the user enters -1, you'll never get out of the nested loop that validates the input. If you want to allow -1, you should... more 4/23/2015 9:02:03 AM

people

Is UNIX time universal

I did some research on internet but still confused. Is UNIX time universal time like GMT/UTC or does it vary from place to place like a local time? I know UNIX time is counted...
Jon Skeet
people
quotationmark

Now If person A and person B use the same function who are sitting in two different time zones, will they get the same result? Yes, they will - assuming their clocks are both "correct" of course. The java.util.Date class is basically... more 4/23/2015 7:18:19 AM

people

Getting error on files.readAllLines

I am working in android. For reading the file content, I am using the method List<String> lines = Files.readAllLines(wiki_path); But whem I am using this method I am...
Jon Skeet
people
quotationmark

The method you're trying to use is a member of java.nio.file.Files - but that class (and indeed that package) doesn't exist on Android. Even if the Java 7 version existed, you're trying to use a method introduced in Java 8. The Files class... more 4/23/2015 6:02:11 AM

people

Would it be possible to call this generic method?

Given the following method of a class which doesn't have type T defined: public <T> T get(java.lang.String name) { /* compiled code */ } Would it be possible to invoke...
Jon Skeet
people
quotationmark

Yes. Just call it with an explicit type argument: foo.<Integer>get("something") I'm not terribly fond of how type arguments are expressed in Java, but they're perfectly doable. See the Java Generics Tutorial for another example. more 4/22/2015 9:21:56 PM

people

Arraylist of objects empty?

so in this class for the choice == 1, it does not go into the for loop through the ArrayList of objects, does it mean the object is empty? because i declared objects at the...
Jon Skeet
people
quotationmark

This is the problem: for (int i = 0 ; i >= store.size(); i++) Unless store is empty (in which case you'll get an exception), i >= store.size() will immediately be false. You meant: for (int i = 0; i < store.size(); i++) Or... more 4/22/2015 9:05:46 PM

people

Passing a string value from c# file to js file

I am trying to pass a string value from c# file to js file. If I try to pass an int value, then I can pass it, but I am unable to pass string value. string value = "abc"; int...
Jon Skeet
people
quotationmark

Consider what your HTML will look like. First version: onclick="F1(abc)" Second version: onclick="F1(5)" Clearly the second version is passing the value 5. The first version is passing the value of abc - whatever that is, within the... more 4/22/2015 5:38:17 PM

people

Override EqualityComparer for LINQ to SQL class

I want to override the EqualityComparer for one of my LINQ to SQL classes (autogenerated by visual studio) so that when I look for a match with IndexOf, it will use my comparison...
Jon Skeet
people
quotationmark

I want to override the EqualityComparer for one of my LINQ to SQL classes I really don't think you do. I think you want to override the Equals method, and probably implement IEquatable<T>. EqualityComparer is meant for an object... more 4/22/2015 5:31:54 PM

people