I am having some problems with some code and I need an extra set of eyes. It appears I've missed something. I am getting a NullPointerException with a Hashtable object, which I can clearly see I've created. So I'm not quite sure why it is happening. I am pretty sure it is do with the code I've posted because I've tested everything else involved.Here is the code where it happens,
I have a little a problem with String object in this class ....
public class Personne { private String nom; private String prenom; private int age; public Personne(){ this(null, null, 0);
[Code] ....
When i call the class personne with the Personne() i get these errors in compiling-time :
Exception in thread "main" java.lang.NullPointerException at java.lang.String.<init>(Unknown Source) at Personne.setNom(Personne.java:18) at Personne.<init>(Personne.java:12) at Personne.<init>(Personne.java:8) at Main.main(Main.java:4) // The line wich i inisialize my object in my main method.
I was browsing around and I found a question asking to find how many times a word occurred in a sentence. I am using a hashtable, over kill yes but I need to use them more. However my counter is not working, not really sure why.You can see in the main method I have two repeating names but it returns 0.
package frequency; import java.util.Hashtable; public class CheckFrequency { hashtable<String, Word> words = new Hashtable<String, Word>();
I am having some difficulty adding a new item to the HashTable when a collision occurs. We can only use the basic utilities to code this, so we are coding a HashTable by hand. We have an array of length of 10, which each index holds or will hold a Node for a Linked List.
The code hashes fine, adds the item, but the problem exists when adding items that already been hashed. The project is much bigger, but this is the engine behind the rest, and I figured I would tackle this first.
The items we are adding are objects which are states containing different information, we hash based on the ASCII sum % tableSize.
Here is the code I am testing with to add items:
HashTable ht = new HashTable(10); State az = new State("Arizona","AZ","W",2,"Y",2); State fl = new State("Florida", "FL", "F", 2, "X", 2); State hi = new State("Hawaii", "HI", "H", 3, "Z", 1); State al = new State("Alabama", "AL", "A", 5, "W", 0); ht.insert(hi);
I'm writing the remove method, where you insert the key and it searches the key, if the key is found you remove the value inside the table and return that value, if they key is not found you return null. I did this method but is not returning anything in the main so I try to print inside an if to see if it was entering the condition and it appears to be looping, I'm using arrays because its an assignment
public V remove(K k) { int key = funcionHash(k); V key2 = (V) tabla[key].value; int intento=1; if(this.estatus[key]==1){ while(intento<this.tabla.length/2){ if(this.tabla[key].key.equals(k)){
I'm having a problem implementing double hashing when I insert a value into the table i get this for the output:
Insert []. Is there something I'm doing wrong? I'm not getting any errors
public static int size = 0; public static ArrayList<Integer>[] a; public static void interactiveMode(Scanner input) { int menuChoice = 0; do { System.out.println(" Interactive Mode:");
I need to implement a separate-chaining hash table from scratch and I don't need to know the code or anything I would just like an explanation of how I would go about doing the algorithm for this perhaps pseudocode and then I can figure out the rest.
I'm having a problem with double hashing, its supposed to have the user insert an integer into the table and the integer is hashed into the table by the mod of the size of the table so say for instance table size 10 I insert 89 that inserts into 9 because 89%10=9 then i insert 18 that goes into 8 but then once i insert 69 its supposed to collide with index 9 and then uses 7-(69%7) for prime number double hashing...but it just goes into index 9 instead so in 9 it puts 89,69...there's no errors just the wrong output
System.out.print("Enter size of table: "); int n = input.nextInt(); size=n; a = new ArrayList[size]; for (int i = 0; i < size; i++) { a[i] = new ArrayList<Integer>();
How can I write a BufferredImage to an 8-bit .bmp using indexed colors stored in a <String,Color> Hashtable?
I've never used Hashtables before, and I didn't know color indexing existed until now, but I can do most other things in java fairly well.
I'm not looking for code, just the concept, as I really don't know how Hashtables work (although I could figure it out), and how color indexing does. I know how to write image files, just not indexed or with a specific number of bits. I am using Hashtables generated from GIMP.
EDIT: I mainly want to know how to save a BufferedImage as an indexed .bmp.
public class CharCountingStudy { public static void main(String[] args) throws FileNotFoundException{ Set<FileExaminer> examiners = new LinkedHashSet<>(); examiners.add(new FileExaminer("raven.txt")); examiners.add(new FileExaminer("jabberwocky.txt"));
[Code] ....
I keep getting a NullPointerException at the "examiners.add(new FileExaminer("raven.txt"));", the "calculateCharCountAlpha();", and the "if (charCountAlpha.containsKey(w)){"and I don't know why it is doing that.
I am getting a NullPointerException Error and I cannot seem to figure out what is causing it. I am reading in a grades1.dat text file and putting the values into a 2D array. The error is occuring in my addGrade method, but I am not sure what the error is. Here are the values for my grades1.dat that I am running in through Run Arguments in JGRASP.
Student1 5 a Activities 0.05 q Quizzes 0.10 p Projects 0.25 e Exams 0.30 f Final 0.30 a100 a95 a100 a100 a100 q90 q80 q100 q80 q80 r90 p100 p95 p100 p85 p100 e77.5 e88 f92
Here are the errors that I am getting.
Exception in thread "main" java.lang.NullPointerException at GradeBook.addGrade(GradeBook.java:114) at GradeBookApp.main(GradeBookApp.java:55) import java.util.Arrays; /** * Stores students name, a char array of category codes, a String array of categories, a double array of category weights, and a two dimensional double array of grades where each row contains all the grades in a particular category.
I have been playing around with my code, but how to avoid NullPointerexception.. So my program's point is simple, use Jsoup to scrape html of certain webpage, then i search the things i want and print them out. Problem is, when scraped html doesnt contain even 1 thing on my search list, i get NullPointerException... i understand why, Heres part of my code:
Java Code:
//Things i need to search from html String[] MySearchArray = new String[]{"138","146","474"}; //Search things contained in MySearchArray and print them out for (String Ml : MySearchArray) { Element flights = doc.select(String.format("tr:contains(%s)", Ml)).first(); Elements flights2 = flights.select("td"); System.out.println(flights2.get(4).text() + " " + flights2.get(0).text()+ " " + flights2.get(3).text()); } mh_sh_highlight_all('java');
I have a jsp page that generate a hashtable and display its key-value pairs back to the browser. The problem is that it takes on an average about 15 minutes to build this hashtable, and as a result, I always get a timeout error. What can I do to avoid getting the timeout error without changing the server configuration for timeout
/** * This method displays all winner names for a given year. * @param year is the integer parameter asked of the user. */ public void displayAllWinnersForYear (int year) { if (year >= 1993 || year <= 2009) { String[] winnersForTheYear = nobelPrizeWinners.get(year); for (int i = 0; i < winnersForTheYear.length; i++) {
[Code] ....
When year is outside the 1993-2009 range, I get a NullPointerException from line 10. Shouldn't it be skipped entirely since the conditions of its parent IF statement (line 7) is not met?
Am new to programming and am trying to create a system that is similar to a train timetable system.I want the user to be able to enter the stops between two stations ( from a preset list of 5 stations ) and this be saved as an array list, and this array list be saved accordingly within a 2D array so if they were to look in [1][2] there would be an arraylist of stops between station 1 and 2.I used this to initialise the array of arraylists (in a class i created called stops)
public void stops(){ for (int i = 0; i<5; i++){ for (int j=0; j<5; j++){ stopsArray[i][j]= new ArrayList<String>(); } } }
Then I use this code to set the stops
public void setNoStops(int stopsNo){ noOfStops = stopsNo; }
[code]...
The bottom written line of code is mentioned in the null pointer error I recieve. Then.Then in my main programme I declare the new object and use these methods the method options displays the list of five stations with a number reference
System.out.println("Please choose a start station :"); options(); place1 = scanner.nextInt(); System.out.println();
System.out.println("Please choose an end station :"); options(); place2 = scanner.nextInt(); System.out.println();
[code]...
mystops is the object I created to store the information.
when compiling I recieve no errors.when I run the program it runs smoothly, asks for the number of stops, allows the user to enter a number, then says enter stop 1, I enter a word and the program crashes giving the error java.lang.NullPointerException
I'm new to web services. Right now i'm trying to consume JAX-WS web service on IBM WebSphere Application Server 7. Sending SOAP message with security header[username, password] parameters. Getting NullPointerException..
Exception :
javax.xml.ws.WebServiceException: java.lang.NullPointerException at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:175) at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70) at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:128) at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMinimalMethod Marshaller.demarshalFaultResponse(DocLitBareMinimalMethodMarshaller.java:443) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:559) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:497) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:404)
I recently switched some of code around to restructure how some things were working but now when I run the program I am getting a NullPointerException in multiple areas. I suspect it may have something to do with a constructor. I am very new to "object" - ish based programming.
I figured I should give a little background on the program, this program is reading from a text file of names and decade numbers(for each name) and storing each line into an object array. From there, there are menus and based on the users decision they can type a name and get a histogram, compare names with histograms, ect. Below this main method, I have provided the area where I have gotten the null pointer exception.
Here is the main method for the Client "nameApp"
Also excuse the formatting and curly braces for now!
And here is the method in the same Client that is getting the null pointer exception:
The pointer exception is on line 6 which is:
if (nameInput.equalsIgnoreCase(list[i].getName())){ private static int checkListArray(String nameInput, Name[] list){ int nameLocation = -1; int listLength = list.length;
I have an arraylist, list, that I need to take the size to declare an array, arr3, in another class. Problem 1: the size is giving me an error of "can not make static reference to non-static method getListSize() from the type FindItemInfo". I tried to change getListSize() to static and it gives me and error another place. I try to then fix that, and I get a new error... and so on.
I am using arr3 to store items the user can not afford. I have this next problem even when I input an integer for the arr3 size. I am getting a NullPointerException, and I can't figure out why the arr3[] is not loading. I tried debugging but can not figure out where I went wrong, especially since this code was working in the last assignment before I changed list[] to an arrayList. It always breaks at line 64, but I believe it has to be somewhere in the cashOut() method.
Relevant code is:
public class FindItemInfo implements InterfacePrint{ ArrayList <ItemAttribute> list = new ArrayList<ItemAttribute>(); //does stuff public void printPriority(){ TransactionCalc finish = new TransactionCalc();
I have a swing application that is using JFileChooser. When I click the Open menu item from File menu it should show the File dialog box where user can select the file.This application is running in my machine but encounters problem in another machine. File dialog box is not showing and stack trace shows that NullPointerException is thrown by JFileChooser..My machine is a 64 bit Windows 7 while the other machine is Windows 7 32 bit. Both machine are using java 1.6..To verify if its because of the 32-bit, I tried in another Windows 7 32-bit and the same application is working.
I came across this article [URL] .... which identified it as bug but already fix in 1.4.2_04. Though I am using 1.6, just to make sure I also tried the suggested work around.I put System.setProperty("swing.disableFileChooserSpeedFix", "true"); in my code but still not working...I also tried to add java -Dswing.disableFileChooserSpeedFix=true to the batch file that is launching the application and still not working
Code Sample:
import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class FileChooserTester{ public Boolean loadMDBFile() { System.setProperty("swing.disableFileChooserSpeedFix", "true"); JFileChooser fc = new JFileChooser();
I'm currently having trouble with a Breakout clone that I'm working on when I want to change the scenes of the game. When I start out with the main menu and I hit play, the main menu calls for the StateManager to remove the MainMenu and then to add the GameState to start playing through the levels. But, whenever this is done it just gives a NullPointerException and freezes the game. I know the code for initially starting a State is fine because that is the same way the MainMenu is loaded but there seems to be an issue with changing from one to another...
This is the StateManager class that adds and removes the States/Canvases to and from the JFrame/Main class:
public class StateManager { private ArrayList<State> states; private int currentState; private JFrame gameFrame; public StateManager(JFrame gameFrame) { this.gameFrame = gameFrame; states = new ArrayList<State>();
[Code] ....
I've tried messing around with the order of which things are added/loading from the StateManager but am just failing to see what I did wrong.
Debugging shows the array MediaPrintableArea[] mpa at J2DPrinter:839 is missing its first element, which causes the exception at line 844.
If I execute
service.getSupportedAttributeValues(MediaPrintableArea.class, null, null) instead of
service.getSupportedAttributeValues(MediaPrintableArea.class, null, pras) I get an array with an element on the first position.
The msn object used for the PrintRequestAttributeSet is "iso-a4", which causes the missing first element in the MediaPrintableArea[] array.
So why does this happen? Am I missing some important config stuff? I tried to fix it myself, but I am not able to debug service.getSupportedAttributeValues(...).
I'm currently having trouble with a Breakout clone that I'm working on when I want to change the scenes of the game. When I start out with the main menu and I hit play, the main menu calls for the StateManager to remove the MainMenu and then to add the GameState to start playing through the levels. But, whenever this is done it just gives a NullPointerException and freezes the game. I know the code for initially starting a State is fine because that is the same way the MainMenu is loaded but there seems to be an issue with changing from one to another...
This is the StateManager class that adds and removes the States/Canvases to and from the JFrame/Main class: package com.pathtocreating.Breakout_V2.state;
import java.awt.BorderLayout; import java.util.ArrayList; import javax.swing.JFrame; public class StateManager { private ArrayList<State> states;
[Code] ....
The code that calls the change of state in MainMenuState is called in the update method:
Here is the full stack trace when clicking the area to change states:
Exception in thread "Thread-2" java.lang.NullPointerException at sun.java2d.SunGraphics2D.validateColor(Unknown Source) at sun.java2d.SunGraphics2D.<init>(Unknown Source) at sun.awt.image.SunVolatileImage.createGraphics(Unknown Source)
[Code] ...
It gives that same value both before and after clicking on the region.
Printing out b after the State is changed to GameState gives the following:
Iva tried flipping the entire code upside down (expression) and No matter what I do the delete function returns a null pointer exception after my while loops takes the pointer right to where it should be.
package bp; import java.time.LocalDate; public class BinaryTree implements IBinaryTree { private Node root = null; private int sizeOfTree = 0;