permaculture playing cards*
The moose likes Beginning Java and the fly likes incompatible types? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "incompatible types?" Watch "incompatible types?" New topic
Author

incompatible types?

kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
public void registrer()
{
if (antall==nyPerson.length) // sjekke om tabellen er fullt
{
System.out.println("Tabellen er fullt.");
}
else
{ // frithjof
String fornavn = Keyboard.readln("Fornavn: ");
String etternavn = Keyboard.readln("Etternavn: ");
int f�dsels�r = Keyboard.readInt("F�dsels�r: ");

int nr = Keyboard.readInt("Nr: ");
int ans�r = Keyboard.readInt("Ansettelses�r: ");
double l�nn = Keyboard.readDouble("L�nn: ");
double skatteprosent = Keyboard.readDouble("Skatteprosent: ");

Person P = new Person(fornavn, etternavn, f�dsels�r);

nyPerson[antall] = new ArbTaker(P,nr,ans�r, l�nn, skatteprosent);
antall++;
} // end else
} // end registrer
----------------------------------
i get this error message :
----------------------------------
register.java [190:1] incompatible types
found : ArbTaker
required: Person
nyPerson[antall] = new ArbTaker(P,nr,ans�r, l�nn, skatteprosent);
^
1 error
Errors compiling register.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30050
    
149

nyPerson was declared as an array of Person objects. But you are trying to put an ArbTaker object into the array. Unless ArbTaker is a subclass of Person, it won't work.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

a small remark:

It's not a good idea to use local characters in code.
Though it matches the idea of good readable code perfectly, there are some tradeoffs:
If you move your code to a different platform/ environment, it might not work.
Some filesystems might refuse to use local available characters in filenames.
If you have to ask questions in forums, or share the code with foreign developers, they might be unable, to use your code - at least it will make them headaches, how to input these characters on their keyboards.
As far as I know, local characters don't build 'valid', 'allowed' code due to the language specification, though it might work.


http://home.arcor.de/hirnstrom/bewerbung
kelvin cheung
Ranch Hand

Joined: Mar 27, 2004
Posts: 120
Jeanne and Stefan,
thank you for the replies !!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: incompatible types?
 
Similar Threads
We cann't instantiate an interface
accessing non-static method from static context
listener dead?
problem with listener
actionEvent problems