我无法从列表中检索数据.这些值似乎永远不会被存储,或者对象被初始化了?我创建了一个存储一些变量的类:
public class storage{
public int a = 0;
public int b = 0;
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了另一个填充a的类,并且b创建了一些值并将该对象存储在列表中
public class anotherclass{
public List<storage> alldata = new ArrayList<storage>();
public void filldata(){
storage tmp = new storage();
for (int i = 1; i <= 10; i++){
tmp.a = i;
tmp.b = i;
alldata.add(tmp);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我在我的主类中运行filldata()时,然后尝试从列表中获取对象a和b仍然设置为0.
public static void main(String[] args){
anotherclass obj = new anotherclass();
obj.filldata()
for (int i = 0; i <= obj.alldata.size() - 1; i++){
System.out.println(obj.alldata.get(i).a)
System.out.println(obj.alldata.get(i).b)
//Outputs as all …Run Code Online (Sandbox Code Playgroud) 如何将像素长度(即宽度和高度为 512 像素的图像)转换为准确的 OpenGL 坐标?
我现在所能做的就是尝试手动猜测 -1 和 1 之间的大小。