编译代码后,我没有收到任何错误或输出。我正在使用netbeans IDE。我该怎么办?

问题描述:

在'Source Packages'下有两个包'mypkg1'和'mypkg2'分别包含'myclass1.java'和'myclass2.java'文件。



myclass1.java

Under the 'Source Packages' there are two packages 'mypkg1' and 'mypkg2' containg 'myclass1.java' and 'myclass2.java' files respectively.

myclass1.java

package mypkg1;

public class myclass1
{

int x,y;
public myclass1(int a,int b)
{
    x=a;
    y=b;
}

public int pdata()
{
    return (x+y);
}


}







myclass2 .java




myclass2.java

package mypkg2;

import mypkg1.myclass1;

class myclass2
{
public static void main(String args[])
{
    int z;

    myclass1 c=new myclass1(1,2);

    z=c.pdata();
    System.out.println("The sum is " + z);

}
}





我的尝试: b $ b

输出:



What I have tried:

Output:

BUILD SUCCESSFUL (total time: 0 seconds)

Quote:

BUILD SUCCESSFUL(总时间:0秒)

BUILD SUCCESSFUL (total time: 0 seconds)



这条消息只是意味着你的代码尊重Java的语法,它并不意味着你的代码是有意义的并且会做你期望的。

句子'猫在天空飞得很高'尊重英语语法,但没有任何意义,因为猫不会飞。



有一个工具允许您查看代码正在执行的操作,其名称是调试器。掌握调试器不是可选的,它对任何程序员都是强制性的,也不例外。

它也是一个很好的学习工具,因为它向你展示了现实,你可以看到哪个期望与现实相符。



当你不明白你的代码在做什么或为什么它做它的作用时,答案是调试器

使用调试器查看代码正在执行的操作。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量,这是一个令人难以置信的学习工具。



调试器 - *,免费的百科全书 [ ^ ]

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html [ ^ ]

https://www.jetbrains.com/idea/help/debugging-your-first-java -application.html [ ^ ]

调试器在这里向您展示您的代码正在做什么,您的任务是与它应该做什么进行比较。

调试器中没有魔法,它没有找到错误,它只是帮助你至。当代码没有达到预期的效果时,你就接近一个bug。


This message just means that your code respect the grammar of Java, it doesn't imply that your code is meaningful and will do what you expect.
The Sentence 'the cat flies high in the sky' respect English grammar, but doesn't mean anything because cats don't fly.

There is a tool that allow you to see what your code is doing, its name is debugger. Mastering the debugger is not optional, it is mandatory for any programmer, no exception.
It is also a great learning tool because it show you reality and you can see which expectation match reality.

When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


当你编译(并可能链接)一个源语言时,系统会产生对象或可执行代码(假设没有错误)。但就是这样,您仍需要运行最终程序以查看任何输出。
When you compile (and possibly link) a source language, the system will produce object or executable code (assuming no errors). But that is all, you still need to run the final program to see any output.