VC中自定义结构体,如下:
typedef struct _listElement {
char type;
int start;
int end;
} listElement, *pListElement;
typedef struct _arrayList {
pListElement array;
int size;
int capacity;
} arrayList, *pArrayList;
函数如下:
pListElement listGet(pArrayList list, int idx) {
if (idx >= list->size || idx < 0)
return NULL;
return list->array + idx;
}这里参数list是结构体指针,返回值类型也为结构体指针。
在java中该如何实现呢??
(我想这个结构体大概可以用类模拟,但是结构体arrayList中的成员pListElement array; 我又该怎么办呢?哎呀,一塌糊涂!!)
请大家指点!谢谢!
typedef struct _listElement {
char type;
int start;
int end;
} listElement, *pListElement;
typedef struct _arrayList {
pListElement array;
int size;
int capacity;
} arrayList, *pArrayList;
函数如下:
pListElement listGet(pArrayList list, int idx) {
if (idx >= list->size || idx < 0)
return NULL;
return list->array + idx;
}这里参数list是结构体指针,返回值类型也为结构体指针。
在java中该如何实现呢??
(我想这个结构体大概可以用类模拟,但是结构体arrayList中的成员pListElement array; 我又该怎么办呢?哎呀,一塌糊涂!!)
请大家指点!谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货