Histogram
--------------------------------------------------------
1 ****(4)
2 ******(6)
3 ***********(11)
4 *****************(17)
5 **************************(26)
6 *************************(25)
7 *******(7)
8 ***(3)
9 (0)
10 *(1)
--------------------------------------------------------
basically above is what my p...
I have a network of Java Threads (Flow-Based Programming) communicating via fixed-capacity channels - running under WindowsXP. What we expected, based on our experience with "green" threads (non-preemptive), would be that threads would switch context less often (thus reducing CPU time) if the channels were made bigger. However, we foun...
I'm trying to turn an array like this:
0, 1, 2, 2, 1, 0, 1, 0, 0, 1, 2
into this:
0 0 0 0 1 1 1 1 2 2 2
Here is my code:
public static int[] sortDNF(int[] tape) {
int smaller = 0; // everything with index < smaller is 0
int bigger = tape.length - 1; // everything with index > bigger is 2
int current = 0; // where we are looking...
I have a BufferedReader looping through a file. When I hit a specific case, I would like to continue looping using a different instance of the reader but starting at this point.
Any ideas for a recommended solution? Create a separate reader, use the mark function, etc.?
...
In the jsp i have:
<%@ include file="/assets/includes/inc_standard_init.jsp" %>
In the browser I get:
org.apache.jasper.JasperException: /oprs.jsp(1,1) File "/assets/includes/inc_standard_init.jsp" not found
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher...
I have a an object that I'd like to grab the contents of in java.
The only problem is that is is currently in ruby.
irb(main):050:0> blah
=> "BAh7ByIeYXV0aGVudGljYXRpb25fc3RyYXRlZ2llczAiCXVzZXJpBg%253D%253D-\
-0cdecf4edfaa5cbe4693c9fb83b204c1256a54a6"
irb(main):049:0> Marshal.load(Base64.decode64(blah))
=> {"authentication_strategies"=...
Is there any way to require that a class have a default (no parameter) constructor, aside from using a reflection check like the following?
(the following would work, but it's hacky and reflection is slow)
boolean valid = false;
for(Constructor<?> c : TParse.class.getConstructors())
{
if(c.getParameterTypes().length == 0) {
...
I'm new to Castor and data binding in general. I'm working on an application that, in part, needs to take data off of a socket and unmarshall the data to make POJOs. Now, I've got the socket stuff down, and I've even generated and compiled java files thanks to Ant and Castor.
Here's the problem: the data stream that I'll receive could b...
Hello, I was wondering if it's possible to write a function that accepts multiple generic types as follows:
public int void myfunction(Set<T> a, Set<T> b) {
return 5;
}
Set<Integer> setA = new HashSet<Integer>();
Set<String> setB = new HashSet<String>();
int result = myfunction(setA, setB);
Will that work? Does the generic in ea...
There are some good explanations of EJB Transaction Attributes (and annotations) out there, for example, OpenEJB's.
But sometimes when I try to cover this with someone who hasn't worked with many transactional resources, I see their eyes start to glaze over.
So my question - how would you explain EJB Transaction Attributes to your gr...
Hello good people!
I've been trying for the this whole a query who is officially giving me nightmares. The system is a user and contact management. So I have UserAccount, Contact and Phone.
UserAccount has a bidirectional one-to-many relationship with Contact and an unidirectional one on phone all mapped by a Set:
//UserAccount ma...
The goal of the assignment that I'm currently working on for my Data Structures class is to create a of Quantum Tic Tac Toe with an AI that plays to win.
Currently, I'm having a bit of trouble finding the most efficient way to represent states.
Overview of current Structure:
AbstractGame
Has and manages AbstractPlayers (game.nextP...
I am trying to change a few hot-keys in the java application I am wokring on and it seems that the system I am using may not work with three button key combinations. We currently have a JMenuItem item and we set the hotkey with a call like this:
menuItem.setAccelerator(getAcceleratorKey(accelerator));
And here is the getAcceleratorKe...
So, I've develop a simple hello world midlet using the Samsung SDK 1.1.2 and I've Packaged the midlet. Now I have two files (a JAR/JAD) combination. How do I get these installed on my phone?
As you can tell from the question, I'm new to phone development. Trying to deploy to a Samsung handset on ATT.
I'm trying to test out the entire ...
If my stored procedure has a print statement inside it:
print 'message'
Is there a way to fetch the output in java program that connects to SQL Server 2008 through JDBC?
Also, is there a danger that print messages left for debugging would shutdown connection when called from JDBC application?
...
I have a blocking queue of objects.
I want to write a thread that blocks till there is a object on the queue. Similar to the functionality provided by BlockingQueue.take().
However, since I do not know if I will be able to process the object successfully, I want to just peek() and not remove the object. I want to remove the object only...
I'm looking for sample Java JMX code to access the values of JMX attributes from another VM.
With JConsole, I have no problem looking at java.lang/Memory/Attributes/HeapMemory
How would I get the same information from a Java program running in a VM?
Examples of any command line options needed, or other things that need to be started a...
Hi, I just got an answer to my seam question about displaying current date. Now I'm searching around to find the place to change the format for this feature. Is that possible?
Thanks.
...
Hey y'all,
I'm trying to write a Java method to preform a 'multi-pop" on a stack, it should "pop" "k" number of items off the top of the stack object. This is what I'm thinking, but it's not quite right, any help out there?
Thanks everyone.
public void multipop(int k){
while (top != null){
for(int i =0; i<=k; i++){
this.pop();
}}}...
Found a sample STaX code in below link:
http://www.javarants.com/2006/04/30/simple-and-efficient-xml-parsing-using-jaxb-2-0/comment-page-1/
The below code doesn't work. I am not what is missing.
JAXBContext ctx = JAXBContext.newInstance("com.sampullara.findbugs.om");
Unmarshaller um = ctx.createUnmarshaller();
int bugs ...