Java子类$

发布于 2024-10-17 13:40:15 字数 167 浏览 2 评论 0原文

我是 Java 新手,可能会问一个对某些人来说可能听起来很愚蠢的基本问题。

编译 Main Java 类后,大多数子类在文件夹中显示为 $。我复制编译的类并将其放在另一个位置来执行。每次我对主类或子类之一进行更改时,是否需要复制所有关联的子类?或者只复制更改的内容就可以了?

谢谢。 缺口

I am new to Java and might be asking a basic question which might sound silly to some.

After I compile my Main Java class most of the subclasses are displayed as $ in the folder. I copy the complied classes and put it on another location to execute. Everytime I make make a change to the main class or one of the sub classes do I need to copy all the associated subclasses? or just copying the changed ones will do?

Thanks.
Nick

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

鱼忆七猫命九 2024-10-24 13:40:15

复制更改即可。

通常,您会让您的 IDE(例如,Netbeans)/构建系统(例如,Ant / Maven)为你做这件事。或者,您可以创建一个可执行文件 jar 文件,只需复制一个文件。

Copying the changes will do.

Normally, you would let your IDE (e.g., Netbeans) / build system (e.g., Ant / Maven) do this for you. Alternatively you could create an executable jar-file, leaving you with only one file to copy.

远昼 2024-10-24 13:40:15

包含 $ 的类名适用于嵌套/匿名类。

请参阅此 Stackoverflow 问题

但这不是重点。引用 OP 我复制编译的类并将其放在另一个位置来执行。 - 看起来您应该自动执行此任务并使用传统的 Java 构建工具之一,例如 AntMaven

Classnames containing $ are for nested/anonymous classes.

And see this Stackoverflow question.

But that's not the whole point. Quoting OP I copy the complied classes and put it on another location to execute. -- looks like you should automate this task and employ one of traditional Java build tools such as Ant or Maven.

呆橘 2024-10-24 13:40:15

尼克,

您指的是嵌套类吗?如果是这样,它们将在编译后的类文件名中包含“$”。假设您的代码更改仅针对父类,则嵌套类字节码在重新编译期间不应更改。它应该只复制主 .class 文件。然而,这显然更能保证复制所有内容。

Nick,

Are you referring to nested classes? If so, they will contain "$" in the compiled class file names. Assuming your code changes were only to the parent class, the nested class bytecode should not have changed during the recompilation. It should work to only copy the main .class file. However, it's obviously more of a guarantee to copy the everything.

ˉ厌 2024-10-24 13:40:15

这是关于子类化(class Y extends X {})还是嵌套类(class Y { class X {} })?

您提到的 $ 似乎表明后者,在这种情况下,您可能应该复制所有内容,但如果您只是子类化,那么只需复制已更改文件的编译版本可能就可以了。

Is this about subclassing (class Y extends X {}), or nested classes (class Y { class X {} })?

The $ that you mention seems to indicate the latter, in which case you should probably copy everything, but if you are only subclassing then just copying the compiled versions of the files you have changed is probably just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文