Skip to content

Tag: java

Java Inner Classes

I’m new to Java and have the following question regarding inner classes: When implementing an inner class, do I need to declare its attributes and methods scope i.e. public, private, protected? EDIT: With the absence of delegates (as in C#) could someone mention how best to implement a messaging system …

Naming convention for utility classes in Java

When writing utility classes in Java, what are some good guidelines to follow? Should packges be “util” or “utils”? Is it ClassUtil or ClassUtils? When is a class a “Helper” or a “Utility”? Utility or Utilities? Or do you use a mixture of them? The standard Java…

Creating a New Reverse Java Array

CodingBat > Java > Array-1 > reverse3: Given an array of ints length 3, return a new array with the elements in reverse order, so {1, 2, 3} becomes {3, 2, 1}. I can’t get this to work properly, usually the last int in the array, becomes every single int in the new array Answer You don’t w…

java generics covariance

I am having trouble understanding the following article: http://www.ibm.com/developerworks/java/library/j-jtp01255.html Under, Generics are not covariant the author states, Because ln is a List, adding a Float to it seems perfectly legal. But if ln were aliased with li, then it would break the type-safety pro…

How do you get the selected value of a Spinner?

I am trying to get the selected items string out of a Spinner. So far I have gotten this: This does not work and gives a class casting exception (I thought I could cast a View to a widget that inherits it. Obviously not!) So how do you get the selected value of a Spinner? Answer To get the selected

Architect desperately wants to use SOAP over JMS

I have used JMS in the past to build application and it works great. Now I work with Architects that would love to use the Spec : SOAP over Java Message Service 1.0. This spec seams overly complicated. I do not see many implementation (Beside the vendors pushing for the spec). Does anyone here is using this s…

how to take user input in Array using java?

how to take user input in Array using Java? i.e we are not initializing it by ourself in our program but the user is going to give its value.. please guide!! Answer Here’s a simple code that reads strings from stdin, adds them into List<String>, and then uses toArray to convert it to String[] (if …

Maven: compile aspectj project containing Java 1.6 source

Primary Question What I want to do is fairly easy. Or so you would think. However, nothing is working properly. Requirement: Using maven, compile Java 1.6 project using AspectJ compiler. Note: Our code cannot compile with javac. That is, it fails compilation if aspects are not woven in (because we have aspect…