本文目录一览:
- 1、java.lang.IndexOutOfBoundsException:
- 2、java.lang.OutOfMemoryError: Java heap space
- 3、我用myeclipse写java代码出了一个异常。我点了一下thread.java。然后就出现了一
- 4、java报错beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based!
- 5、为什么 beyond compare 不能打开java的class文件,提示转换错误
java.lang.IndexOutOfBoundsException:
该异常通常是指数组下标越界异常。
例如:一个ArrayList数组中没有元素,而你想获取第一个元素,运行是就会报此类型的错误。
案例如下:
扩展资料:
java中还有其他几种常见异常
1、java.lang.NullPointerException
该异常的解释是"程序遇上了空指针",简单地说就是调用了未经初始化的对象或者是不存在的对象,这个错误经常出现在创建图片,调用数组这些操作中,比如图片未经初始化,或者图片创建时的路径错误等等。
2、java.lang.ClassNotFoundException
该异常的解释是“指定的类不存在”,这里主要考虑一下类的名称和路径是否正确即可,如果是在eclipse等开发工具下做的程序包,一般都是默认加上Package的,所以转到WTK下后要注意把Package的路径加上。
3、java.lang.ArithmeticException
该异常的解释是“数学运算异常”,比如程序中出现了除以零这样的运算就会出这样的异常,对这种异常,要检查一下自己程序中涉及到数学运算的地方,公式是不是有不妥。
4、java.lang.ArrayIndexOutOfBoundsException
该异常的解释是“数组下标越界”,现在程序中大多都有对数组的操作,因此在调用数组的时候一定要认真检查,看自己调用的下标是不是超出了数组的范围。
5、java.lang.IllegalArgumentException
该异常的解释是“方法的参数错误”,很多J2ME的类库中的方法在一些情况下都会引发这样的错误,比如音量调节方法中的音量参数如果写成负数就会出现这个异常。
6、java.sql.SQLException
该异常的解释是“Sql语句执行异常”,由数据库管理系统抛出至服务器,应检查sql语句是否书写正确等。
参考资料:jdk9官方文档-Exception类
java.lang.OutOfMemoryError: Java heap space
Java的堆内存溢出了,可能是由于你的某个方法BUG导致的,比如构造了一个List,一次放入的数据过多,或者一次读取某个很大的文件,而没有使用缓存
根本的解决方法是查找导致溢出的方法,并修正(可以减少放入内存的内容)
另外有一个治标的方法:在WEB容器启动时加上内存参数:
-Xms512m -Xmx512m
如果改JVM不行,那就查看下是否程序上有问题。
---------------此问题答案引用于:beyondts
我用myeclipse写java代码出了一个异常。我点了一下thread.java。然后就出现了一
package java.lang;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.AccessControlContext;
import java.security.PrivilegedAction;
import java.util.Map;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.LockSupport;
import sun.nio.ch.Interruptible;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import sun.security.util.SecurityConstants;
/**
* A ithread/i is a thread of execution in a program. The Java
* Virtual Machine allows an application to have multiple threads of
* execution running concurrently.
* p
* Every thread has a priority. Threads with higher priority are
* executed in preference to threads with lower priority. Each thread
* may or may not also be marked as a daemon. When code running in
* some thread creates a new codeThread/code object, the new
* thread has its priority initially set equal to the priority of the
* creating thread, and is a daemon thread if and only if the
* creating thread is a daemon.
* p
* When a Java Virtual Machine starts up, there is usually a single
* non-daemon thread (which typically calls the method named
* codemain/code of some designated class). The Java Virtual
* Machine continues to execute threads until either of the following
* occurs:
* ul
* liThe codeexit/code method of class codeRuntime/code has been
* called and the security manager has permitted the exit operation
* to take place.
* liAll threads that are not daemon threads have died, either by
* returning from the call to the coderun/code method or by
* throwing an exception that propagates beyond the coderun/code
* method.
* /ul
* p
* There are two ways to create a new thread of execution. One is to
* declare a class to be a subclass of codeThread/code. This
* subclass should override the coderun/code method of class
* codeThread/code. An instance of the subclass can then be
* allocated and started. For example, a thread that computes primes
* larger than a stated value could be written as follows:
* phrblockquotepre
* class PrimeThread extends Thread {
* long minPrime;
* PrimeThread(long minPrime) {
* this.minPrime = minPrime;
* }
*
* public void run() {
* // compute primes larger than minPrime
* . . .
* }
* }
* /pre/blockquotehr
* p
* The following code would then create a thread and start it running:
* pblockquotepre
* PrimeThread p = new PrimeThread(143);
* p.start();
* /pre/blockquote
* p
* The other way to create a thread is to declare a class that
* implements the codeRunnable/code interface. That class then
* implements the coderun/code method. An instance of the class can
* then be allocated, passed as an argument when creating
* codeThread/code, and started. The same example in this other
* style looks like the following:
* phrblockquotepre
* class PrimeRun implements Runnable {
* long minPrime;
* PrimeRun(long minPrime) {
* this.minPrime = minPrime;
* }
*
* public void run() {
* // compute primes larger than minPrime
* . . .
* }
* }
* /pre/blockquotehr
* p
* The following code would then create a thread and start it running:
* pblockquotepre
* PrimeRun p = new PrimeRun(143);
* new Thread(p).start();
* /pre/blockquote
* p
* Every thread has a name for identification purposes. More than
* one thread may have the same name. If a name is not specified when
* a thread is created, a new name is generated for it.
* p
* Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
* thrown.
*
* @author unascribed
* @see Runnable
* @see Runtime#exit(int)
* @see #run()
* @see #stop()
* @since JDK1.0
*/
public
class Thread implements Runnable {
中间省略...
/* Some private helper methods */
private native void setPriority0(int newPriority);
private native void stop0(Object o);
private native void suspend0();
private native void resume0();
private native void interrupt0();
private native void setNativeName(String name);
}
对比下 这个就是 线程 Thread 类 2058行
java报错beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based!
hql多了参数了,你就一个占位符 - 即?,却使用了query.setParameter(2, "%" + filter.getKeyWord() + "%");
为什么 beyond compare 不能打开java的class文件,提示转换错误
用 Beyond Compare 3 的 Data Compare 可以达到目的: 在 Data Compare 两侧载入文件(或剪贴板内容),Data Compare 会自动识别分隔符并分列。 下面进行“对齐B列”的操作: 打开菜单:Session Session Settings... (也可点击工具栏中的 Rules 工具按钮) 在打开的 [Data Compare - Session Settings] 对话框中,选择 Columns 标签页: 在这个列表中,点选 [Left file] 列中要对齐的项(你的例子中,就是你所说的B列的列名),用 Move Up/Move Down 把它与 [Right file] 列中的相关项对齐,确定。 现在,在 Data Compare 两侧,你所说的B列的列序已经一致了。 然后,通过列标的右键菜单,把你的B列设为“Key Column”,把其余各列设为“Standard Column”。 现在,两侧内容已经依据“Key Column”的内容进行了“行对齐”。 然后,点击相应的工具栏按钮: 关闭 Left Orphans 和 Right Orphans; 开启 Same 和 Differences。 现在,Data Compare 两侧所剩的就是“B列相同的行”了。 然后,通过列标右键菜单中的“Hide Column”,隐藏你的B列。 现在,Data Compare 两侧剩下的就是你要的内容了。 你可以把两侧的内容复制到文本编辑器里。 也可以用 Session Data Compare Report... 输出结果: [Data Compare Report] 的选项: Report layout: Side-by-side Report options: [Same, Differences] Output options: Plain text 然后,你在文本编辑器里对这个输出结果稍加整理即可。