public class complex_c { public static int antal_komplexa_tal = 0; public complex_c() { this( 0, 0 ); } // complex_c public complex_c( float re, float im ) { this.re = re; this.im = im; complex_c.antal_komplexa_tal++; } // complex_c protected void finalize() throws Throwable { super.finalize(); complex_c.antal_komplexa_tal--; } // finalize public void skriv_tal() { System.out.print( this.re + " + " + this.im + "i" ); } // skriv_tal private float re, im; public static void main( String args[] ) { complex_c cvektor[] = new complex_c[3]; for ( int index = 0; index < 3; index++ ) { cvektor[index] = new complex_c(); } // while { complex_c snart_ur_scope = new complex_c(); System.out.println( complex_c.antal_komplexa_tal + " med snart_ur_scope." ); } System.out.println( complex_c.antal_komplexa_tal + " utan snart_ur_scope." ); } // main } // class complex_c