2015-10-16 52 views
0

我试图来显示使用System.out.println阵列INT值的数组,但我不断得到当Eclipse是试图运行代码中的警告消息:打印含有的System.out.println

“的内部发生了错误详细信息 “”,并在”: -java.lang.NullPointerException

下面是代码:

import java.util.Arrays; 

public class testerArray { 
    public static void main(String[] args) { 
     int [] test = {-1, -1, -1, -1};  
     System.out.println(java.util.Arrays.toString(test)); 
    } 
} 

我在这个网站上搜索了很多解决方案,但是我一定已经失明了,因为我不能看到我做的不同于本网站上的答案中使用的示例。我做错了什么?

这里是堆栈跟踪:

java.lang.NullPointerException 
at org.eclipse.ui.part.PageBookView.showPageRec(PageBookView.java:1000) 
atorg.eclipse.ui.internal.console.ConsoleView.showPageRec(ConsoleView.ava:171) 
at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:779) 
at org.eclipse.ui.internal.console.ConsoleView.display(ConsoleView.java:531) 
at org.eclipse.ui.internal.console.ConsoleManager$ShowConsoleViewJob.runInUIThread(ConsoleManager.java:313) 
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:97) 
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) 
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136) 
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3983) 
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) 
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151) 
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032) 
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148) 
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636) 
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579) 
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) 
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135) 
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) 
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) 
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) 
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at java.lang.NullPointerException 
at org.eclipse.ui.part.PageBookView.showPageRec(PageBookView.java:1000) 
at org.eclipse.ui.internal.console.ConsoleView.showPageRec(ConsoleView.java:171) 
at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:779) 
at org.eclipse.ui.internal.console.ConsoleView.display(ConsoleView.java:531) 
at org.eclipse.ui.internal.console.ConsoleManager$ShowConsoleViewJob.runInUIThread(ConsoleManager.java:313) 
at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:97) 
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) 
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136) 
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3983) 
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660) 
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151) 
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032) 
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148) 
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636) 
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) 
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579) 
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) 
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135) 
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134) 
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104) 
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) 
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648) 
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603) 
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648) 
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603) 
at org.eclipse.equinox.launcher.Main.run(Main.java:1465) 
+4

此代码正常工作 - 您的问题在其他地方(或者您没有运行您认为正在运行的代码)... – assylias

+0

是的,它应该可以正常工作。 – SacJn

+0

是不是应该更新日食或类似的东西? – user820913

回答

1

这看起来更像是一个比一个代码问题Eclipse的问题(在堆栈跟踪,你会看到,从问题的起源是在Eclipse类)。你为什么不尝试在没有Eclipse的情况下运行这个文件? http://www.cs.swarthmore.edu/~newhall/unixhelp/debuggingtips_Java.html#compiling

这样,如果它有效,你就会知道它是一个Eclipse问题。

+0

谢谢!至少我知道什么是问题,而不是实际的代码。改变工作空间也解决了这个问题。 – user820913

相关问题