As my two friend Alaa & Foaud are writing [Problem of the week] 

i am also writing Problem NOT of the week 😀

bcoz i wont write a problem weekly in addition to i dont know the solution of my problems 🙂 almost…



during my internship time i spent in Mentor Graphics Cairo i needed to implement a function

and when i started coding i found that it was impossible to do it that way

may be there is a way that function can be implemented but i dont know how due to my small experience with JAVA

Here is the problem definition:

Programming Language used : of course u know its JAVA what r u looking at 😛


Problem context:

-I have an object of type Design

-I have an object of type Diagram

-The Design contains one or more Diagrams



-I have an Iterator<Design>

-form that iterator i need the next Design and an Iterator<Diagram> and a Diagram

-The function should return boolean value weather it succeeded or not


My First implementation was:

boolean getNext ( Iterator<Design> designs , Design currentDesign , Iterator<Diagram> Diagrams , Diagram currentDiagram )


      if (! designs.HasNext() )

           return false;

     currentDesign =;

     Diagrams = currentDesign.getDiagramIterator();

     currentDiagram =;


     return true;

//It compleeeetly didn’t work because JAVA has no passing by reference !!!




  i cant make the three variables ( currentDesign , Diagrams, currentDiagram ) global as they are created in the calling function



What did i do …..

Copy & Paste those line every where i needed that function 😛