Easy Coding
  Forum Wiki Tagging Projekte Karte RSS
» Start
» All Recent Changes
» Wiki Suche
» Wiki Hilfe

Informationen

How To's Algorithmen

edit SideBar

Neue Wiki Eintrage finden Sie unter easy-coding.de/wiki.

Anonyme-Klasse

Eine lokale-Klasse ohne eigenen Namen heißt anonym.

Eine anonyme Klasse kann nur einmal instanziert werden

AnonymeKlasse.java
  1. public class AnonymeKlasse
  2. {
  3.         public static void printTable(Funktion m)
  4.         {
  5.                 System.out.println("Wertetabelle " + m);
  6.                 for (double x=0.0; x<=5.0; x+=1) {
  7.                         System.out.println(x + “->“ +
  8.                         m.compute(x));
  9.                 }
  10.         }
  11.  
  12.         public static void main(String[] args)
  13.         {
  14.                 printTable (new Funktion() {
  15.                                 public double compute(double x) {
  16.                                         return x*x;
  17.                                 }
  18.                 });
  19.         }
  20. }
Zuletzt geändert am 01.10.2006 10:10 Uhr
  Impressum