“代码太大"Java中的编译错误 [英] "Code too large" compilation error in Java

查看:47
本文介绍了“代码太大"Java中的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 中的代码有任何最大大小吗?我写了一个超过 10,000 行的函数.实际上,每一行都为一个数组变量赋值.

Is there any maximum size for code in Java? I wrote a function with more than 10,000 lines. Actually, each line assigns a value to an array variable.

arts_bag[10792]="newyorkartworld";
arts_bag[10793]="leningradschool";
arts_bag[10794]="mailart";
arts_bag[10795]="artspan";
arts_bag[10796]="watercolor";
arts_bag[10797]="sculptures";
arts_bag[10798]="stonesculpture"; 

编译时出现这个错误:代码太大

And while compiling, I get this error: code too large

我该如何克服?

推荐答案

Java 类中的单个方法最多可能有 64KB 的字节码.

A single method in a Java class may be at most 64KB of bytecode.

但你应该清理它!

使用 .properties 文件存储这些数据,并通过 java.util.Properties

Use .properties file to store this data, and load it via java.util.Properties

您可以通过将 .properties 文件放在您的类路径中来完成此操作,并使用:

You can do this by placing the .properties file on your classpath, and use:

Properties properties = new Properties();
InputStream inputStream = getClass().getResourceAsStream("yourfile.properties");
properties.load(inputStream);

这篇关于“代码太大"Java中的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆