0 Replies - 470 Views - Last Post: 03 April 2013 - 08:07 AM Rate Topic: -----

#1 bobrown101  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 02-April 13

***error*** Exception in thread "main" java.lang.NullPointerEx

Posted 03 April 2013 - 08:07 AM

I'm making a simple hangman application. This is the class that will see where the letter is in the word
import java.lang.String;

public class char_array {
	main main = new main();
	String word; // this will be some word the person would be trying to guess like "brady"
	String x; // this is the letter the operator guesses , so it would be like "b"
	
	public char_array(String a, String B)/>{
		a = this.word;
		b = this.x;
	}

	public void some_function() {
		
		char charArray[]=word.toCharArray();
		for(int h=0;h<charArray.length;h++){
		    System.out.println("Data at ["+h+"]="+charArray[h]);//this is just to test
		}
	
	}

}




this is the error I get
 
Exception in thread "main" java.lang.NullPointerException
	at char_array.some_function(char_array.java:15)
	at main.main(main.java:47)



the error doesn't really tell me much. Can you guys help?

Is This A Good Question/Topic? 0
  • +

Page 1 of 1