【发布时间】:2014-04-24 23:41:01
【问题描述】:
我正在尝试制作一个正在处理的图表,但不断收到“ArrayIndexOutOfBounds”错误。我很难理解 map() 语法的概念,有人可以帮我弄清楚吗?我不确定 map(x,y,z,a,b) 中的每个数字应该代表什么;
String[] name = {
"1st:",
"5th:",
"10th:",
"15th:",
"20th:",
"25th:",
"30th:"
};
int[] temperature = {
81,
82,
84,
85,
87,
88,
90
};
void setup(){
size(200,200);
}
void draw(){
int x=0;
for(int i=0;i<10;i++){
if(mouseX>x && mouseX<=x+40){
fill(255,40,40);
}else{
fill(50);
}
float h = map(temperature[i], 0, 100, 0, 200);
rect(x+4,height-h,32,h);
x+=40;
}
}
【问题讨论】:
-
你能发布你得到的异常的堆栈跟踪吗?
-
map()方法属于哪个类?
-
您没有向我们展示您的 map() 方法或它的文档,因此我们无法猜测,但您的
ArrayIndexOutOfBoundsException的原因非常清楚,请参阅我的回答。
标签: java maps processing