Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 10th, 2006, 7:31 AM   #1
flamblob
Newbie
 
Join Date: Nov 2006
Posts: 1
Rep Power: 0 flamblob is on a distinguished road
Exclamation Help with object arrays

hey all, im trying to learn java and im having some trouble grasping arrays pointing to objects. All of my programs fail to compile with the same "cannot resolve symbol" error. I made a simplified script to show you what I am talking about. It gives me the symbol error and points to uno[count].theThing(). This would be the same in all my other programs regardless of the object name. I can't figure this out!!

class test {
public static void main(String[] args) {
int x=3; // the number of spots in the array
int x1; // a copy
theThing[] uno; // declare the array
uno = new theThing[x]; //give 3 spots to array
x1 = x; //copy x
while (x1>0) {
uno[x1] = new theThing();	//make the objects
x1--;

}// end while

tester(x); //go to the method
System.exit(0);

}// end main

static void tester(int count) {
while (count>0) {
System.out.println(uno[count].theThing()); //calls to theThing for theNumber
count--;
}// end while

}// end tester


}// end class test


class theThing {
int theNumber = 77;
int theThing() {
return theNumber;
}// end theNumber

}//end theThing
flamblob is offline   Reply With Quote
Old Nov 10th, 2006, 7:43 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 894
Rep Power: 4 The Dark is on a distinguished road
The uno variable is declared in main, you can't access it inside a different function.
You either have to pass it in, or make uno a static member of the test class.
The Dark is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Level Editor frankish Show Off Your Open Source Projects 47 Jul 10th, 2006 7:57 PM
Library problem creating Direct3d Object Kilo C++ 9 May 30th, 2006 9:48 AM
Arrays or Vectors? can342man C++ 2 Apr 20th, 2006 4:57 PM
Arrays in PHP MrMan9879 PHP 6 Jan 12th, 2006 10:18 PM
references passed through parameters, do they copy the object or reference the orig? cypherkronis Python 1 Jun 30th, 2005 8:38 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC