473,473 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

calling an array....

22 New Member
Hi,
basically i have got the code all sorted just need to know how to call the array - heres the code;

public int sortArray()
{
Comparable[] a = {People.ArrayList(people[])};
Comparable[] sortedArray = main.sort(a);
}


the bold section is the part i am stuck with.

My array is in class People and in method ArrayList.
My array is called people.

any ideas would be great,
thanks
dave
May 2 '07 #1
5 1879
Ganon11
3,652 Recognized Expert Specialist
Instead of using people[], try people.
May 2 '07 #2
ShaveDave27
22 New Member
Instead of using people[], try people.
Hi,
Thanks for the reply, i tried it as just people and it didnt compile either but it had a different error message, first it said ".class expected". Now it says cant find variable people.

any ideas?
May 2 '07 #3
Ganon11
3,652 Recognized Expert Specialist
I'm not sure what you're trying to do...Try

Expand|Select|Wrap|Line Numbers
  1. Comparable[] a = people;
since each Person is a Comparable object, and people is an array of People, this might work.
May 2 '07 #4
JosAH
11,448 Recognized Expert MVP
I'm not sure what you're trying to do...Try

Expand|Select|Wrap|Line Numbers
  1. Comparable[] a = people;
since each Person is a Comparable object, and people is an array of People, this might work.
No it doesn't work for a very clear reason but extremely hidden: if a D is a B
that doesn't make an array of D an array of B. Here's a nice example:
Expand|Select|Wrap|Line Numbers
  1. class MeansOfTransportation { ... }
  2. class Car extends MeansOfTransportation { ... }
  3. class Submarine extends MeansOfTransportation { ... }
Now a carpark is a "Car[]", but a carpark isn't a "MeansOfTransportation[]"
because you don't want any submarines in there ;-)

kind regards,

Jos
May 2 '07 #5
Ganon11
3,652 Recognized Expert Specialist
I don't know who you're fooling - I have submarines in my carpark!
May 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: I_have_nothing | last post by:
Hi! I am new in C. I try to use dynamical allocation fuction malloc( ) and realloc( ). I found something strange. After several calling realloc( ), the malloc( ) will give me a Segmentation...
0
by: Richard Mathis | last post by:
My problem is rather complicated (for me), so I'm going to post my problem here as well as what I've done so far to solve my problem. Any assistance would be appreciated. I originally posted this...
3
by: cees | last post by:
Hi, I need to call an external C-function that accept an array of void pointers (void **). Each item can either be a single float,int,char or a C-array of these types. Is that possible and if so...
14
by: Microsoft | last post by:
I know how to call a finction and pass a parameter to it, but I don;t understand how to take the resulting output of the function and use it from the subroutine that called the function ...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
3
by: Jayman777 | last post by:
Hello, I am using PHP 4.4.1 and am having problems retrieving an object from an array of objects and then calling a method on it. Here are two simple classes that I am using: class Day...
7
by: Andreas Reiff | last post by:
Hey! I have a managed c++ app (actually, the app is mixed managed/unmanaged, but this happens in the managed part) that dynamically generates some program in c# (with CSharpCodeProvider). The...
1
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the...
5
by: kelvin.koogan | last post by:
How can I call a function in a Delphi DLL from C++/CLI? The Delphi function is declared as follows: function Func1(IsDsb: Boolean; FirstStr, SecondStr : String): String; I've tried ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.