I know is possible to increase Java heap before calling the program, like this:
java -Xmx6g myprogram
But it's possible do the same thing with a Java command? Example:
public class AddTwoIntegers {
public static void main(String[] args) {
System.IncreaseMyHeap
int first = 10;
int second = 20;
System.out.println("Enter two numbers: " + first + " " + second);
int sum = first + second;
System.out.println("The sum is: " + sum);
}
}