Topic: 为什么数组下标越界都能编译过去呢?

  Print this page

1.为什么数组下标越界都能编译过去呢? Copy to clipboard
Posted by: nothing
Posted on: 2004-10-08 10:08

Big SmileBig Smile

不能运行,但是居然能编译过去..怕怕...



package untitled2;

public class StrLenth {
public static void main(String[] args) {

String sB[] = new String[3];
sB[0] = new String("hello");
sB[1] = "world";
sB[13]="坏蛋";
System.out.println(sB[0] + " " + sB[13]);

int iC[]=new int[3];
iC[19]=16;
System.out.println(iC);


}
}


2.Re:为什么数组下标越界都能编译过去呢? [Re: nothing] Copy to clipboard
Posted by: why
Posted on: 2004-10-08 10:28

Is there any computer language that supports this type of bound-checking?

3.Re:为什么数组下标越界都能编译过去呢? [Re: nothing] Copy to clipboard
Posted by: nothing
Posted on: 2004-10-08 10:46

SadSadSad

4.Re:为什么数组下标越界都能编译过去呢? [Re: nothing] Copy to clipboard
Posted by: alexlex
Posted on: 2004-10-08 15:39

本來就是運行時檢查的 所以會降低運行效率 而不是編譯效率

5.Re:为什么数组下标越界都能编译过去呢? [Re: nothing] Copy to clipboard
Posted by: westwin
Posted on: 2004-10-12 17:30

编译时不检查,运行时才检查,所以说ArrayIndexOutOfBoundsException是
RuntimeException


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923