Java - Arrays and Methods

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Java - Arrays and Methods

Post by d3ad1ysp0rk »

Just learning the basics so bear with me.
I've tried searching google for this, but I'm not exactly sure what to look for.

Basically, I'm trying to change this:

Code: Select all

public static int size(){
int size = list.size();
return size;
}
to use arrays.

or in other words, what's the correct syntax for passng arrays through methods (both to them and returning an array).

thanks.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

You could use the ArrayList class, http://java.sun.com/j2se/1.4.2/docs/api ... yList.html which is the default Java2 array management structure.

Scorphus.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

thanks for the link, but I asked my friend in school and he said,

for arraylists:

Code: Select all

public whatever ArrayList name(){
and for arrays:

Code: Select all

either
public whatever int name(){
or
public whatever intї] name(){
or string[]/string or w/e u need.

hopefully these work.. thanks for the help tho :)
Post Reply