- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display the maximum amount of memory in Java
In order to display the maximum amount of memory in Java, we use the maxMemory() method. It is a method of the java.lang.Runtime Class. It returns the maximum amount of memory that the Java Virtual Machine will try to use.
Declaration − The java.lang.Runtime.maxMemory() method is declared as follows −
public long maxMemory()
Let us see a program to display the maximum amount of memory in Java −
Example
public class Example { public static void main(String[] args) { // print statement at the start of the program System.out.println("Start..."); // displays the maximum memory System.out.println(Runtime.getRuntime().maxMemory()); } }
Output
Start... 119537664
Advertisements