Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Dec 1st, 2005, 11:25 PM   #21
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 290
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
Quote:
Originally Posted by titaniumdecoy
No, one is a basic data type and the other is an object.
Yes, but in the context of ArrayList, you cannot specify <int>. You must use <Integer>. You may then use it as a int.

Such as:
myArray.add(5);

if (myArray.get(0) == 5) {
    System.out.println("Yep, it was 5");
}
andro is offline   Reply With Quote
Old Dec 1st, 2005, 11:50 PM   #22
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 837
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Ok... how come
ArrayList[][] possible = new ArrayList[9][9];
works fine, but
ArrayList<Byte>[][] possible = new ArrayList<Byte>[9][9];
doesn't? They seem like the same thing to me.
titaniumdecoy is offline   Reply With Quote
Old Dec 2nd, 2005, 7:15 AM   #23
groovicus
Programmer
 
Join Date: Nov 2004
Posts: 84
Rep Power: 4 groovicus is on a distinguished road
Shouldn't it be declared like this?
ArrayList<Byte>[][] possible = new ArrayList[9][9];
__________________
HijackThis Team-SFDC
groovicus is offline   Reply With Quote
Old Dec 2nd, 2005, 7:25 AM   #24
Master
Programmer
 
Master's Avatar
 
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 3 Master is on a distinguished road
you have to declare it with <> because ArrayList is a template class which allow you to create ArrayList of any data type. I hope i am not wrong ^_^
Master is offline   Reply With Quote
Old Dec 2nd, 2005, 1:37 PM   #25
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
I had to declare my ArrayList like this:
ArrayList<MyPoint> points=new ArrayList<MyPoint>();
But my situation could be different, since I'm using my own object and I'm creating an empty, one-dimensional ArrayList. I'm not sure if that changes anything...
Writlaus is offline   Reply With Quote
Old Dec 3rd, 2005, 11:39 AM   #26
2roll4life7
Programmer
 
2roll4life7's Avatar
 
Join Date: Aug 2005
Location: 0x0010 * 0x0091 + 0x0004
Posts: 65
Rep Power: 3 2roll4life7 is on a distinguished road
Or you can go oldschool 1.4.2 and don't use the template. Then you could just declare an ArrayList object and add new Integer objects too it (called a wrapper class).
__________________
#if 0 /* in case someone actually tries to compile this */
- libpng version 1.2.8 (example.c)

<Jim_McNeat> Is there like a way to put a compiler in "Just trust me on that one" mode?
2roll4life7 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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:02 PM.

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