Here you can find the source of maxMemory()
public static String maxMemory()
//package com.java2s; //License from project: Open Source License public class Main { private static final long MEGA = 1024 * 1024; public static String maxMemory() { long maxMemory = Runtime.getRuntime().maxMemory(); return convertLongToMega(maxMemory); }/*ww w. java 2s .co m*/ private static String convertLongToMega(long value) { long megaValue = value / MEGA; String result = Long.toString(megaValue) + " MB"; return result; } }