Java子类$
我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
复制更改即可。
通常,您会让您的 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.
包含
$
的类名适用于嵌套/匿名类。请参阅此 Stackoverflow 问题。
但这不是重点。引用 OP
我复制编译的类并将其放在另一个位置来执行。
- 看起来您应该自动执行此任务并使用传统的 Java 构建工具之一,例如Ant
或Maven
。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 asAnt
orMaven
.尼克,
您指的是嵌套类吗?如果是这样,它们将在编译后的类文件名中包含“$”。假设您的代码更改仅针对父类,则嵌套类字节码在重新编译期间不应更改。它应该只复制主 .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.
这是关于子类化(
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.