This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Array place getting null itself Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Array place getting null itself" Watch "Array place getting null itself" New topic
Author

Array place getting null itself

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

Hello,
i have 2D array and initialise it with nested loop. More specific in place array[11][2] initialise it as element of another class i created. Now if i use system.out to print this place after the end of loop, content is ok, but if i print it in a method i created is null!!! Im not doing anything in that place in that method, just system.out. Any idea???
thank you

EDIT: Noticed that in method all elements of the array are NULL.Why? when that happens?
Wim Vanni
Ranch Hand

Joined: Apr 06, 2011
Posts: 96

Without seeing any code I can think of a few possible causes:
- scope
- assignment going wrong
- ..

Wim
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9939
    
    6

it is impossible to say without seeing your code. Clearly you are doing something wrong, or not doing something right. So please post what you have (and only the relevant part please!!!).


Never ascribe to malice that which can be adequately explained by stupidity.
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 490

If all the elements of your array or null it seems like your initializing the array incorrectly. Look through the Java array tutorial and see if that helps you figure it out.
http://download.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Hunter

"If the facts don't fit the theory, get new facts" --Albert Einstein
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Array place getting null itself
 
Similar Threads
JLabel
initialising String variables in an array
Access an array, from different class. How?
Calling a method
String parameters at command line......