wood burning stoves 2.0
The moose likes Beginning Java and the fly likes whats wrong with this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "whats wrong with this code" Watch "whats wrong with this code" New topic

whats wrong with this code

ali pak

Joined: Nov 24, 2001
Posts: 6
// why i am getting NullPointerException
class a
public static void main(String[] args)
b[] x = new b[5];
x[0].xx = "ali";
class b
String xx;
Murtuza Thaver

Joined: Nov 05, 2001
Posts: 3
My guess is u havent initialized the strings in the array correctly.This link might be helpful
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9056

// why i am getting NullPointerException

x[0] is null, so you have null.xx which doesn't work.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link: http://aspose.com/file-tools
subject: whats wrong with this code
jQuery in Action, 3rd edition