What is it!!

 
public class Q4
{
//====================================================
   public static int a(int b, int c) //<--  what happens here???
   {
      int x=0;
      x=c-b;
      return x;
   }
//===================================================
   public static int b(int c, int d) //<--  here it is again??
  {
      int x;

      if (c<d)
      {
         x=a(c,d);
      }
      else
      {
         if (d<c)
         {
            x=a(d,c);
         }
         else
         {
            x=0;
         }
      }
      return x;
   }

   public static void main(String args[])
   {
      int a=3;
      int b=-3;
      int x=10;

      x=b(a,b);
      System.out.print(x);
      x=b(b,a);
      System.out.print(x);
   }
}

Hi everyone, i have looked and looked, what does the function int a(int b, int c) do. I know it returns x but to what i have never seen this before.

and also x=a(d,c) i just dont understand the stuff in brackets, im only used to 1 variable being in there...whats the comma do?? This is not for a test or assignment, however i will fail if i dont learn this.

 
Neil_Cave:

Hi everyone, i have looked and looked, what does the function int a(int b, int c) do. I know it returns x but to what i have never seen this before.

and also x=a(d,c) i just dont understand the stuff in brackets, im only used to 1 variable being in there...whats the comma do?? This is not for a test or assignment, however i will fail if i dont learn this.

Hi Neil_Cave,

What you see there is called a structure, a very well known concept in Object Oriented Programming (OOP). MQL4 is not an OOP language therefore it does not recognize structure.

However MQL5 is an OOP, therefore it recognize structure https://www.mql5.com/en/docs/basis/oop.

Now, I'm not gonna explain any further what is structure and then what is class - an expanded concept of structure, coz there's already explanation about it on the web. Perhaps, for a start you can google structure and class and also read from here http://www.cplusplus.com/doc/tutorial/structures/ and http://www.cplusplus.com/doc/tutorial/classes/.

:D

 
Neil_Cave:

Hi everyone, i have looked and looked, what does the function int a(int b, int c) do. I know it returns x but to what i have never seen this before.

and also x=a(d,c) i just dont understand the stuff in brackets, im only used to 1 variable being in there...whats the comma do?? This is not for a test or assignment, however i will fail if i dont learn this.


Have you tried asking on a Forum related to Java ?
Reason: