473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

.class expected

Hi, I am doing an apartment rentals program but i need to bubble sort the array of a user defined class customerDetails (this entails all the details of the customer) However, when i am calling that there is an error:
------------------------------------------------------------------------------------------------------------
apartmentRentalCode.java:476: '.class' expected
Bubblesort(customer[], n );
^
apartmentRentalCode.java:476: ')' expected
Bubblesort(customer[], n );
^
2 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
--------------------------------------------------------------------------------------------------------------
Here is the code:
public void sortCustomer()
{
customerDetails[] customer = new customerDetails[myCustomerLinkedList.sizeOfCustomerList() - 1];
int[] cusIDArray = new int[myCustomerLinkedList.sizeOfCustomerList()-1];
int z = 0;
File fileName = new File("C:\\Users\\Sony\\Desktop\\ComputerScienceDos sier\\JavaCode3\\customerInBinary.dat");
int cusID = 0;
customerDetails readCustomerRecord = new customerDetails();
char status;
char[] fName = new char[30];
char[] lName = new char[30];
char[] dob = new char[10];
char[] passportNo = new char[10];
char[] mobileNo = new char[10];
char[] email = new char[50];
int j = 0;

try {
RandomAccessFile raf = new RandomAccessFile(fileName, "r");
raf.seek(0);
try {
while (true){
status = raf.readChar();
readCustomerRecord.cusID = raf.readInt();

for(j=0; j<30; j++) {
fName[j] = raf.readChar();
}
readCustomerRecord.fName = readCustomerRecord.fName.copyValueOf(fName);

for(j=0; j<30; j++) {
lName[j] = raf.readChar();
}
readCustomerRecord.lName = readCustomerRecord.lName.copyValueOf(lName);

for(j=0; j<10; j++) {
dob[j] = raf.readChar();
}
readCustomerRecord.dob = readCustomerRecord.dob.copyValueOf(dob);

for(j=0; j<10; j++) {
passportNo[j] = raf.readChar();
}

readCustomerRecord.passportNo = readCustomerRecord.passportNo.copyValueOf(passport No);

for(j=0; j<10; j++) {
mobileNo[j] = raf.readChar();
}

readCustomerRecord.mobileNo = readCustomerRecord.mobileNo.copyValueOf(mobileNo);

for(j=0; j<50; j++) {
email[j] = raf.readChar();
}

readCustomerRecord.email = readCustomerRecord.email.copyValueOf(email);
cusIDArray[z] = readCustomerRecord.cusID;
customer[z] = readCustomerRecord;
}


}
catch (EOFException eof){
raf.close();
}
catch (IOException E){
System.out.println( "Problems reading " + fileName );
raf.close();

}

}
catch (IOException X){

System.out.println("IO Problems with " + fileName );

}
int a = 0;
int n =myCustomerLinkedList.sizeOfCustomerList()-1;
System.out.println(n);
Bubblesort(customer[], n );
for(a = 0; a < n; a++){
System.out.println(cusIDArray[a]);
}


}
public void Bubblesort (customerDetails data[],int n) {
int i,j;
customerDetails tmp;

for (i=0; i<n-1; i++) {
for (j=0; j<n-i-1; j++)
if (data[j].cusID > data[j+1].cusID) {
tmp = data[j];
data[j] = data[j+1];
data[j+1] = tmp;
}
}
}
--------------------------------------------------------------------------------------------------------------
can u please help me figure this out...my brain is dead after hours of fiddling around...
cheers x
Mar 13 '09 #1
4 4512
JosAH
11,448 Expert 8TB
When you want to pass an array to a method as a parameter you simply mentions its name, i.e. you don't use the square brackets. so:

Expand|Select|Wrap|Line Numbers
  1. Bubblesort(customer, n );
  2.  
btw, there is also no need to pass the length of the array as well, i.e. the array 'knows' its length.

kind regards,

Jos
Mar 13 '09 #2
many thanks :)
but now i am getting a null pointer exception [line is in italics]
I know the file is there, i have checked the path as well.
Q: is it fine to put data[j].cusID when the array has cusID as part of it?
------------------------------------------------------------------------------------------------------
public void Bubblesort (customerDetails data[],int n) {
int i,j;
customerDetails tmp;

for (i=0; i<n-1; i++) {
for (j=0; j<n-i-1; j++)
if (data[j].cusID > data[j+1].cusID) {
tmp = data[j];
data[j] = data[j+1];
data[j+1] = tmp;
}
}
}
----------------------------------------------------------------------------------------------------
I don't know what is null?? - any ideas?

cheers x
Mar 14 '09 #3
JosAH
11,448 Expert 8TB
Every non-primitive (i.e. not int, double etc.) variable actually is just a reference, a pointer to an object. You have to make it point to an object. For member variables, if you don't make it point to an object, it is said to point to nothing which is represented by the value 'null', i.e. such a variable has a value null. Of course you can't dereference ('use the dot notation') on a variable with a null value.

kind regards,

Jos
Mar 14 '09 #4
Thanks I will check again.

cheers x
Mar 15 '09 #5

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

Similar topics

4
by: Edvard Majakari | last post by:
Hi, I just found py.test and converted a large unit test module to py.test format (which is actually almost-no-format-at-all, but I won't get there now). Having 348 test cases in the module and...
10
by: Chiller | last post by:
Ok, this is a continuation of a problem I posted on an earlier thread. I've started another thread because my problem has progressed from the initial constructor problem into a general method...
12
by: Andrew Jaffe | last post by:
Hi, I have a class with various class-level variables which are used to store global state information for all instances of a class. These are set by a classmethod as in the following (in...
166
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
2
by: Rafał Maj Raf256 | last post by:
Test case: #include <boost/shared_ptr.hpp> using namespace boost; template <typename typ1> class cData { public: template <typename T> T As() { } // As };
2
by: brasewel | last post by:
Hi guys, I'm getting an error i cannot figure. Here is my code Header file ------------------------------------------------------------------------------------------- #ifndef Clock_H #define...
3
by: jdurancomas | last post by:
Dear all, I'm trying to declare the operator++ to a nested class. The nested class is not template but the container it is. The code used in teh sample program is included bellow: ...
10
by: famat | last post by:
Hi all, I have C++ source code that compiles on windows-MS VS2005 without any problem. I am trying to compile it in Linux gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4) and I ran into the following...
2
by: A.J. Bonnema | last post by:
Hi all, I just started using Python. I used to do some Java programming, so I am not completely blank. I have a small question about how classes get instantiated within other classes. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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...

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.