我的dto类中有以下代码.
public void setBillDate(Date billDate) {
this.billDate = billDate;
}
Run Code Online (Sandbox Code Playgroud)
而且我在声纳中出现错误,我不知道我在这里做错了什么.
Malicious code vulnerability - May expose internal representation by incorporating reference to mutable object
Run Code Online (Sandbox Code Playgroud)
该类是一个dto,该方法是自动创建的setter方法.我在这做错了什么.如果有人能解释.这将是一个很大的帮助.
现在,我有一个Point对象数组,我想对该数组进行复制.
我试过以下方法:
1) Point[] temp = mypointarray;
2) Point[] temp = (Point[]) mypointarray.clone();
3)
Point[] temp = new Point[mypointarray.length];
System.arraycopy(mypointarray, 0, temp, 0, mypointarray.length);
Run Code Online (Sandbox Code Playgroud)
但所有这些方式都证明只有mypointarray的引用是为temp创建的,而不是副本.
例如,当我将mypointarray [0]的x坐标更改为1(原始值为0)时,temp [0]的x坐标也会更改为1(我发誓我没有触摸temp).
那么有没有办法制作Point数组的副本?
谢谢
我正在写一个基于John Conway的生命游戏的程序.我得到它编译,甚至在经过几天不间断的工作后运行.但是,打印出来的结果是错误的......
这是我的代码(不包括主要方法)
//clears the grid
public static void clearGrid ( boolean[][] grid )
{
for(int row = 0; row < 18; row++){
for(int col = 0; col < 18; col++){
grid[row][col]= false;
}
}
//set all index in array to false
}
//generate the next generation
public static void genNextGrid ( boolean[][] grid )
{
int n; //number of neighbors
boolean[][] TempGrid = grid;// a temporary array
for(int row = 0; row < 18; row++)
{
for(int col = …Run Code Online (Sandbox Code Playgroud)