View Single Post
  #1 (permalink)  
Old 07-31-2007, 07:26 PM
aleplgr aleplgr is offline
Member
 
Join Date: Jul 2007
Posts: 5
aleplgr is on a distinguished road
why does not execute this?
Hi! In this code I print one message before and after executing the method obtenirInstanciaUnica, those 2 messages are actually displayed in the console, so far so good:

Code:
private void jbInit() throws Exception { System.out.println("before obtenirInstanciaUnica"); gestor = GestorKlass.obtenirInstanciaUnica(Integer.parseInt(param.obtenirMaximMatrius())); System.out.println("after obtenirInstanciaUnica");
Here's the method, in the constructor GestorKlass I try to display a message

Code:
public static synchronized GestorKlass obtenirInstanciaUnica(int maxMats){ System.out.println("I AM HEREEEEEEE"); if (instancia == null) instancia = new GestorKlass(maxMats); return instancia; } private GestorKlass(int max){ System.out.println("I AM CONSTRUCTING HERE"); maxMatrius = max; numMatriusOcupades = 0; matriusCarregades = new GestorMatriu[maxMatrius]; }
The question is WHY does not it write anything else to the console? it should show the message in the obtenirInstanciaUnica method first line, and also the message in the constructor, seems as if this method is not executed, but it is because It returns the gestor variable which is used all around the rest of the program and it works fine, I don't understand ..

Last edited by levent : 07-31-2007 at 09:07 PM. Reason: Codes are placed inside [code] tag.
Reply With Quote
Sponsored Links