I was asked in an interview what is the advantage of using iterator over for loop or what is the advantage of using for loop over iterator? Can any body please answer this? Answer First of all, there are 2 kinds of for loops, which behave very differently. One uses indices: This kind of loop isn’t alway…
Web Service Authentication to Online Federated Dynamics CRM 2013 from Java
I am working on a Java program to integrate via web services with a Microsoft Dynamics CRM 2013 online version. Authentication is federated with a local IDP, not through Windows Live. I am having problems finding documentation on how to complete this. All of the non-.NET environment documentation I have seen …
How to generate a CUSIP check digit
CUSIPs are a 9-digit alphanumeric code for uniquely identifying a financial security. https://en.wikipedia.org/wiki/CUSIP They were invented in the 1964, and given the reliability of data transmission in the 60’s, the 9th digit is actually a check digit used to confirm the validity of the first 8 charac…
Jackson Json Deserialisation: Unrecognized field “…” , not marked as ignorable
I’m getting the following error and no resolution i found did the trick for me: Unrecognized field “GaugeDeviceId” (Class GaugeDevice), not marked as ignorable The problem seems, that the service returns the property names with a leading upper letter, while the class properties begin with a …
Java – Asteroids – acceleration in two dimensions
I am currently writing Asteroids for extra credit in my computer science class, following a very loose guide that provided some starter code. I have a ship and I can use key presses to change its position. The starter code provided a method of drawing the ship based on a Point position. I was then given this …
Reliance on default encoding, what should I use and why?
FindBugs reports a bug: Reliance on default encoding Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and spec…
Throw exception vs Logging
Is the following way to code good practice? Moreover, should I.. use only the logger? throw only the exception? do both? I understand that with throw I can catch the exception in another part of the callstack, but maybe additional logging has some hidden benefits and is useful as well. Answer I use both in so…
difference between %20 and %2 in url
The java application that I am developing right now is posting an url and some part of the url is like this: asset=travel%2Ccar%2Chouse%2Cbusiness is there any difference with %20 and %2 in the urls?…
Invalid Availability Zone when creating Instance
I’m attempting to create instance on us-west-1c (though I get the same error when trying 1b, or any other AZ) and I’m getting this error: I can manually create the instance via the AWS console. Here is my code to create that instance: I’ve looked over this a hundred times, compared to other …
Is it a bad practice to use a ThreadLocal Object for storing web request metadata?
I am working on a j2ee webapp divided in several modules. I have some metadata such as user name and preferences that I would like to access from everywhere in the app, and maybe also gather data similar to logging information but specific to a request and store it in those metadata so that I could optionally…