Hi all,

I have a constructor with 2 numbers both set as longs

however

in my driver class, it is showing as an error, even after casting the already longs to a long again.

This is constructor

public Personal(String forename, String surname, long dob, String add1, String add2, String county, long telNumber)
    {
    	this.forename = forename;
        this.surname = surname;
        this.dob = dob;
        this.add1 = add1;
        this.add2 = add2;
        this.county = county;
        this.telNumber = telNumber;

     }

And this is the line of code giving the "number too big for int" error

personalList[0] = new Personal("Paul "," White ", 074078L , "51 Princes Street", "North Shields", "Tyne and Wear", 7852384379L);

note the two numbers are cast as long, the error occurs with/without casting.

Cheers

Paul

Where are the declarations of dob and telnumber (the instance variables, not the parameters)?

they are in the same class as "public personal"

private long dob;
private long telNumber;

public long getDob()
{
return dob;
}
public long getTelNumber()
{
return telNumber;
}

I think you need to remove the '0' from the first number:

personalList[0] = new Personal("Paul "," White ", [B]0[/B]74078L , "51 Princes Street", "North Shields", "Tyne and Wear", 7852384379L);

thank you so much, thats the boyo!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.