• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

incompatible types?

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 41093
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
kelvin cheung
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne and Stefan,
thank you for the replies !!
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic