[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

java: nedarve fra klasse med privat konstruktor



Jeg vil gerne skrive en klasse som nedarver fra en anden klasse, som
tilfældigvis kun har en privat konstruktor. 

Eksempel: 
public class EnAndensKlasse{
  private EnAndensKlasse(){ }
}

public class MinKlasse extends EnAndensKlasse{
  private MinKlasse(){ }
}

Desværre vil min editor (Eclipse 3.1M4) ikke lade mig gøre det, thi den
påstår at: 
"Implicit super constructor EnAndensKlasse() is not visible.
Must explicitly invoke another constructor"

Det forstår jeg, fordi en Java konstruktor altid laver et implicit
kald til super() som det første, medmindre det første i en konstruktor
er et kald til this(). 
Hvis jeg laver en ny konstruktor, f.eks. MinKlasse(
String s), vil den stadig skulle kalde enten super() eller this(
nogetandet)... Betyder det at en klasse med (kun) en privat konstruktor,
egentlig er en "final" klasse - altså en ikke-nedarvbar klasse, eller er
der et smuthul jeg har overset? (Og hvorfor fan... erklærer man ikke bare
klassen final, hvis det er det man vil...)


Mvh
Kenneth


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *