



Applies to:
General java, runtime.
Description:
The error 'java.lang.OutOfMemoryError: Java heap space' is caused when the JVM (Java Virtual Machine) runs out of available memory during processing. This can be caused by:
* a system with less memory than your application / VM requires.
When
Because tmp is always true, the while loop never stops and it continues to add the variable i into the vector until the JVM runs out of memory.
Example
Output
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Vector.ensureCapacityHelper(Unknown Source)
at java.util.Vector.add(Unknown Source)
at OutOfMemory.main(OutOfMemory.java:10)
Solution(s)
* add more RAM
* typ: java -Xmx256m in your console window or java -XmxYYYm where YYY is the amount of memory you want to set.
* make sure the condition will ultimately break out of the loop.




Applies to:
General java
Description:
Getting the contents of a substring that is shorter than the specified length
When
Length of a string is 16 but when using the substring method to get a string length of 17 an StringIndexOutOfBoundsException will occur.
Example
output
Length of the string: 16
is a
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 17
at java.lang.String.substring(Unknown Source)
at StringExceptionDemo.main(StringExceptionDemo.java:10)


More Options ...
Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 