Which one is better and why? This one: or this: Answer The first one is better. It’s more consistent with other event functions in the Activity API, it costs you nothing (the code you’re calling does nothing at the moment), and it means you don’t need to remember to add the call in the futur…
Tag: java
Is my package structure correct?
What should be the hierarchy of packages? Is this package structure appropriate? Answer I am actually against layer-driven packaging but instead I advice feature-driven approach: The reasoning is: you’ll much more often want to have all classes related to person functionality in one place. Not often you…
Eclipse is executing the wrong Java file
I am using Eclipse to write and test Java. I am a beginner so i don’t know anything about Eclipse. The problem occurs when I try to run the Java file I just wrote. Instead of executing the file that is opened, it executes the file that I have successfully ran before. I have a few files in the same
Java Returning method which returns arraylist?
I have one class with a method like this: how can i call this method inside another class? Answer 1. If that class from which you want to call this method, is in the same package, then create an instance of this class and call the method. 2. Use Composition 3. It would be better to have a Generic ArrayList
JMS AUTO_ACKNOWLEDGE when is it acknowledged?
I have tried to google this, but have not been successful. If I am using AUTO_ACKNOWLEDGE, and I have a consumer client written in Java, when is the message acknowledged? I am using a MessageListener which contains an onMessage method. Is the acknowledgement sent back to the server before onMessage or after o…
BubbleSort Implementation
I tried to make an implementation of bubble sort, but I am not sure whether it is correct or not. If you can give it a look and if it is a bubble sort and can be done in better way please don’t be shy. Here is the code: Answer This is the calssical implementation for bubble sort and it
Mockito: Trying to spy on method is calling the original method
I’m using Mockito 1.9.0. I want mock the behaviour for a single method of a class in a JUnit test, so I have The problem is, in the second line, myClassSpy.method1() is actually getting called, resulting in an exception. The only reason I’m using mocks is so that later, whenever myClassSpy.method1…
spring-data-mongo – optional query parameters?
I am using spring-data mongo with the JSON based query methods, and am unsure how to allow optional parameters in a search query. For instance – say I had the following function -but I didnt want to apply the name regex match, or not apply a date range restriction if NULL values were passed to the metho…
Conflict between ValidationMessages.properties files
I use to collect all my validation constraints in a common library. In the root of the jar I put a ValidationMessages_it.properties file. All works fine, if I put this library into a jsf 2 war project …
When to use @QueryParam vs @PathParam
I am not asking the question that is already asked here: What is the difference between @PathParam and @QueryParam This is a “best practices” or convention question. When would you use @PathParam vs @QueryParam. What I can think of that the decision might be using the two to differentiate the info…