This is odd. A co-worker asked about the implementation of myArray.hashCode() in java. I thought I knew but then I ran a few tests. Check the code below. The odd think I noticed is that when I wrote the first sys out the results were different. Note that it's almost like it's reporting a memory address and modifying the class moved ...
Hi,
I have a dropdown box in my GUI which shows the contents of an ArrayList in another class.
New objects can be added to the ArrayList elsewhere in the GUI, so I need to know when it is updated, so I can refresh the dropdown menu. From what I can gather, my two options are to extend the ArrayList class to allow me to add my own change...
http://logging.apache.org/chainsaw/quicktour.html
First feature.
I completed the tutorial, it simply showed how to visually use the GUI, it didn't go into much detail at all regarding this new feature. The best documentation I have found is this:
Just as Appenders send logging events outside of the log4j environment (to files, to s...
I wrote a little Linq like DSL on top of Google Collections
public class IterableQuery {
public static <T> Where<T> from(Iterable<T> originalCollection) {
return new Where<T>( Iterables.transform(originalCollection, IterableQuery.<T>SAME()));
}
private static <T> Function<T, T> SAME() {
return new Function<T...
I am using the getResponseBody() method of the org.apache.commons.httpclient.methods.PostMethod class. However, I am always getting a message written to the console at runtime:
WARNING: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
In the code I have to write the response...
I'm debating whether to use Seam, Wicket, JSF or GWT as the foundation for my presentation layer in a Java project.
I narrowed my selection of Java web frameworks down to this subset based on job market considerations, newness of the technology and recommendations from other S.O. users.
What factors should I take into consideration in...
I'm trying to find a simple Java API for creating graph relationships - addEdge(), addNode(), isConnected(node1, node2), findPaths(node1, node2), etc. No UI, just logic. I can find a bunch of academic projects, but none seems to be "The Definitive Graph API".
Does anyone know if such a thing exists?
...
I have a Struts 1 web application that needs to upload fairly large files (>50 MBytes) from the client to the server. I'm currently using its built-in org.apache.struts.upload.DiskMultipartRequestHandler to handle the HTTP POST multipart/form-data requests. It's working properly, but it's also very very slow, uploading at about 100 KBy...
Recently I've been doing a lot of these
enum Thing {
/* etc etc */
static final Set<Thing> allThings = EnumSet.allOf(Thing.class);
}
I want something similar in pre 1.5 Java, i.e. I want something like:
final class Thing {
private Thing(); // control instances within class
static final Thing instance0 = new Thing...
If there is Maven does it at all make sense to learn and use Ant?
...
Is there any library that can be used for analyzing (nlp) simple english text. For example it would be perfect if it can do that;
Input: "I am going"
Output: I, go, present continuous tense
...
Does adding -Xmx argument when running a Java program cause the garbage collector to act differently or occur less often?
...
I would like a regular expression to match given a partial or camel cased string. For example, if the search set contains the string "MyPossibleResultString" I want to be able to match it with the likes of the following:
MyPossibleResultString
MPRS
MPRString
MyPosResStr
M
I'd also like to include wildcard matching, e.g.:
MyP*RStrin...
I am assuming Java has some built-in way to do this.
Given a date, how can I determine the date one day prior to that date?
For example, suppose I am given 3/1/2009. The previous date is 2/28/2009. If I had been given 3/1/2008, the previous date would have been 2/29/2008.
...
For some reason which I can't figure out for the life of me, my text in my JOGL hello world program won't show up at all. I'll include the display method so you'll all know what I'm talking about.
public void display(GLAutoDrawable gLDrawable)
{
final GL gl = gLDrawable.getGL();
final GLU glu = new GLU();
GLU...
I started to use Sun's ClassDep as a solution to fight the inclusion of unnecessary JARs in my resulting WAR application. It seems to rock. However, this beast is hard to tame!
I'm getting several errors of classes not found even if they are explicitly included in the classpath I pass to it. Example:
couldn't find: org.apache.log4j.Log...
I want to have a Class object, but I want to force whatever class it represents to extend class A and implement interface B.
I can do:
Class<? extends ClassA>
Or:
Class<? extends InterfaceB>
but I can't do both. Is there a way to do this?
...
Hey guys!
I'm working on a Java Bomberman clone, using a grid system, and I'm not really satisfied with the movement right now. When the player presses a movement key, the character starts to move (with 0.25 speed). The player loses the control, and the character keeps moving until it has moved a full tile. The player only regains contr...
I hope that in this post, I can get people's opinions on best practices for the interface between JSF pages and backing beans.
One thing that I never can settle on is the structure of my backing beans. Furthermore, I have never found a good article on the subject (correct me if I'm wrong).
What properties belong on which backing beans?...
How come in java we cannot do:
List<List<? extends Number>> aList = new ArrayList<List<Number>>();
Even though this is OK:
List<? extends Number> aList = new ArrayList<Number>();
Compiler error message is:
Type mismatch: cannot convert from ArrayList<List<Number>> to List<List<? extends Number>>
...