" code太大"在Java编译错误 [英] "Code too large" compilation error in Java
问题描述
有没有在Java code的最大尺寸?我写了一个函数有超过10,000行。其实,每一行分配一个值到一个数组变量。
arts_bag [10792] =newyorkartworld;
arts_bag [10793] =leningradschool;
arts_bag [10794] =mailart;
arts_bag [10795] =artspan;
arts_bag [10796] =水彩画;
arts_bag [10797] =雕塑;
arts_bag [10798] =stonesculpture;
和在编译时,我得到这个错误:code过大
我如何克服呢?
在Java类中的一个方法可能是在字节code最64KB。
块引用>但你应该打扫一下!
使用
的.properties
文件来存储这些数据,并通过<一个加载href=\"http://java.sun.com/javase/6/docs/api/java/util/Properties.html\"><$c$c>java.util.Properties$c$c>您可以通过将
的.properties
文件在classpath做到这一点,使用:属性属性=新特性();
为InputStream的InputStream =的getClass()的getResourceAsStream(yourfile.properties);
properties.load(InputStream的);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
How do I overcome this?
解决方案A single method in a Java class may be at most 64KB of bytecode.
But you should clean this up!
Use
.properties
file to store this data, and load it viajava.util.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);
这篇关于&QUOT; code太大&QUOT;在Java编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!