I get a null pointer exception when a call a method on a custom class. I do not see why my object p of class Player is null. (Player is a class of Players of my game) play is the method. This class should create n number of p objects of the Player class and run the play method on them.
import java.util.*;
public class PsychicGameMore
...
Hey SO Guru's im having one heck of a job with this code
public void kill(double GrowthRate, int Death)
{
int before = population.size();
for (PopulationMember p : population)
{
int[] probs = ProbablityArrayDeath(GrowthRate,Death,(int)p.fitness());
if (probs[RandomNumberGen.nextRandomInt(0, 99)]==0)
...
Hi all,
I am planning to create a multi lingual keyboard using Java. can u give some ideas or suggestions for doing that? Is there any open source code or interface which i can use in my code?
...
I wrote this for self education. How does it look? (It passes all my junit tests.)
/**
* find needle in haystack
* @param haystack a sorted list
* @param needle
* @return i such that <code>haystack[i] == needle</code>, or -1 if it is not found
*/
public static int find(char[] haystack, char needle) {
int minWindow = 0; // lower ...
When new data is entered in the GUI and exported to the following file it replaces the existing data, how would i prevent this and make it add to the existing data?
thanks
public void exportContacts()
{
FileOutputStream file;
PrintStream out;
try { file = new FileOutputStream("../files/example.buab");
out...
I imagine this is simple - but I can't find the right combination of search terms to get an answer. If I have a multi-module application, how do I get the beans in module A available to the beans in module B.
The project setup looks a little like this:
project.ear/module-a.jar/resources/beans.xml
project.ear/module-a.jar/java/foo/bar.c...
I need to call a web service using ksoap2, I have been doign this successfully up till the point where I need to pass a more complex type to the web service.
Does anybody have an example of passing a complex type to a webservice, preferably, only using SoapObject (the object in question is only Strings and dateTimes.
Thanks
in advance
...
Hi I'm having trouble using the Java JFileChooser and was wondering if anyone could help me out. It's probably something really simple but I just cant spot whats wrong.
The JFileChooser window opens fine when I click my import button and I can navigate to any field but I just cant read them into my JTextFields.
Heres my JFileChooser m...
I have the following code. I want to get hold of the outer class object using which I created the inner class object inner. How can I do it?
public class OuterClass {
public class InnerClass {
private String name = "Peakit";
}
public static void main(String[] args) {
OuterClass outer = new OuterClass();
Inne...
In messages.properties:
error.code=This is error message.\nThis is next line of error message.
Now, when I set "errors.rejectValue" with this "error.code" for a form field, I cannot get the line break of '\n' to display on the jsp page when displaying the error message using the form:errors element.
Instead of '\n', using <br/> also ...
Hello,
Long story:
I am doing a project for my functional programing class, and I thought of writing an AI controller in Lisp, for the Mario AI competition.
I was looking over frameworks/libraries/ways of calling Lisp code from Java, or even better Lisp-Java intercommunication.
I have looked at Jacol, but it is old, and it does not ...
I have to work with a large number of compiled Java classes which didn't specify explicitly specify a serialVersionUID. Because their UIDs were arbitrarily generated by the compiler, many of the classes which need to be serialized and deserialized end up causing exceptions, even though the actual class definitions match up. (This is all ...
This method keeps throwing the exception in the title, and I cannot find a reason, I have created other tables through the connection and all the referenced tables have been created. I'm using embedded JavaDB.
private void createEvidenceTable() throws SQLException
{
Statement evidenceTable = CONNECTION.createStatement();
evidenc...
I'm looking at the manifest.mf for some apache libraries. While I can guess what Export-Package means, I can't find any documentation for these attributes ? Could anyone point me in the right direction.
Here.s an example:
Manifest-Version: 1.0
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Built-By: pemben
Implementation-Title: Commons Be...
How can I check whether a file exists, before openinging it for reading in Java? (equivalent of Perl's -e $filename).
The only similar question on SO dealt with writing the file and was thus answered using FileWriter which is obviously not applicable here.
If possible I'd prefer a real API call returning true/false as opposed to some...
I'm trying to use resteasy to serve out some entities fetched by spring-hibernate.
I've configured one method which returns a POJO and works as expected:
@GET
@Path("/test")
@Produces(MediaType.APPLICATION_XML)
public Episode getTestEpisode() {
Episode e = new Episode();
e.setEpisodename("test");
return e;
}
Produces:
<episod...
Let's say a java codebase has a package called "com.example".
At runtime, we can get this Package by calling
Package p = Package.getPackage( "com.example" ); //(returns null)
or even get a list of all packages by calling
Packages[] ps = Package.getPackages();
The problem is - if the ClassLoader has not yet loaded any class from th...
I thought Java had short circuit evaluation, yet this line is still throwing a null pointer exception:
if( (perfectAgent != null) && (perfectAgent.getAddress().equals(entry.getKey())) ) {
In this case perfectAgent is null, so I just want the whole expression to return false, but my app is still crashing on this line with a NullPointer...
I'm working on an Spring application with lots of input forms. I'd like to reuse the field length in the UI-form, validation and JPA annotations. Is there an elegant way to solve this. My solution at the moment is, to use constants to declare the length:
public class Person
{
public static final int FIRSTNAME_LENGTH = 25;
@Column...
I'm using the Stanford NLP Parsing toolkit. Given a word in the lexicon, how can I find its frequency*? Or, given a frequency rank, how can I determine the corresponding word?
*in the entire language, not just the text sample.
This is a demo of the toolkit I'm using:
class ParserDemo {
public static void main(String[] args) {
Le...