+ Start a Discussion
sreejasreeja 

how to execute the java code

public class Test {

public static void main(String[] args)
{
integer  a = 20;

 system.debug(a);
}
}

how to execute in the anonymous window:??


 i have tried with this code ,it was working fine;;public class Test {


  public class test{
public static void main()
{
integer  a = 20;

 system.debug(a);
}
}

 in anonymous window:test.main(); -- i got 20 . but trying to execute with javacode in salesforce
Best Answer chosen by sreeja
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sreeja,

Greetings to you!

You're missing the parameter in the anonymous window while calling the method. You need to call it like:
 
List<String> result = new List<String>();
Test.main(result);

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Sreeja,

Greetings to you!

You're missing the parameter in the anonymous window while calling the method. You need to call it like:
 
List<String> result = new List<String>();
Test.main(result);

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
sreejasreeja
thanks khan anas.