import java.text.DecimalFormat; public class Main { public static void main(String[] args) { DecimalFormat df = new DecimalFormat("0.00"); long maxMem = Runtime.getRuntime().maxMemory(); System.out.println(df.format(maxMem / 1000000F) + " MB"); } }