JAVA返回值为字符串数组的函数为什么返回值会变 5
publicstaticintflag=0;publicstaticString[]dd=newString[]{"g","f","e","d","c","b","a"}...
public static int flag=0;
public static String[] dd=new String []{"g","f","e","d","c","b","a"};//中间变量
public static String[] ddd=new String []{"g","f","e","d","c","b","a"};
public static String[] dd4=new String []{"g","f","e","d","c","b","a"};//中间变量
public static int change=1000;//初始化change,第一次赋值
public static String[] arraySelfOrder(String [] d,int x,int y)
{
System.out.println("change............"+change);
if(y==0)x=x+1;
for(int i=x;i<d.length-1;i++ )
{
int aa=oneStandardArrayOneArrayQueueOder(d);
System.out.println("aa==========="+aa);
if(change>=aa)
{
change=aa;
flag=i;
System.out.println("minchange================="+change+"y============"+flag);
for(int t=0;t<dd.length;t++)
{
dd[t]=d[t];
}
for(int t=0;t<ddd.length;t++)
{
ddd[t]=dd[t];
}
for(int t=0;t<dd4.length;t++)
{
dd4[t]=ddd[t];
}
System.out.println("min----ddd[]t///////////////////////////////");
for(int t=0;t<d.length;t++)
{
System.out.print(ddd[t]);
}
}
String temp=" ";
temp=d[i];
d[i]=d[i+1];
d[i+1]=temp;
}
System.out.println("min----dd[]t///////////////////////////////");
for(int t=0;t<dd.length;t++)
{
System.out.print(dd[t]);
}
System.out.println("min----ddd[]t///////////////////////////////");
for(int t=0;t<ddd.length;t++)
{
System.out.print(ddd[t]);
}
System.out.println("min----dd4[]t///////////////////////////////");
for(int t=0;t<ddd.length;t++)
{
System.out.print(dd4[t]);
}
return dd;
}
dd,ddd,dd4任意一被return 数组值就会改变,而另外两个是正确的值,为什么只要一return值就变?想了很久也不得,望高人指点 展开
public static String[] dd=new String []{"g","f","e","d","c","b","a"};//中间变量
public static String[] ddd=new String []{"g","f","e","d","c","b","a"};
public static String[] dd4=new String []{"g","f","e","d","c","b","a"};//中间变量
public static int change=1000;//初始化change,第一次赋值
public static String[] arraySelfOrder(String [] d,int x,int y)
{
System.out.println("change............"+change);
if(y==0)x=x+1;
for(int i=x;i<d.length-1;i++ )
{
int aa=oneStandardArrayOneArrayQueueOder(d);
System.out.println("aa==========="+aa);
if(change>=aa)
{
change=aa;
flag=i;
System.out.println("minchange================="+change+"y============"+flag);
for(int t=0;t<dd.length;t++)
{
dd[t]=d[t];
}
for(int t=0;t<ddd.length;t++)
{
ddd[t]=dd[t];
}
for(int t=0;t<dd4.length;t++)
{
dd4[t]=ddd[t];
}
System.out.println("min----ddd[]t///////////////////////////////");
for(int t=0;t<d.length;t++)
{
System.out.print(ddd[t]);
}
}
String temp=" ";
temp=d[i];
d[i]=d[i+1];
d[i+1]=temp;
}
System.out.println("min----dd[]t///////////////////////////////");
for(int t=0;t<dd.length;t++)
{
System.out.print(dd[t]);
}
System.out.println("min----ddd[]t///////////////////////////////");
for(int t=0;t<ddd.length;t++)
{
System.out.print(ddd[t]);
}
System.out.println("min----dd4[]t///////////////////////////////");
for(int t=0;t<ddd.length;t++)
{
System.out.print(dd4[t]);
}
return dd;
}
dd,ddd,dd4任意一被return 数组值就会改变,而另外两个是正确的值,为什么只要一return值就变?想了很久也不得,望高人指点 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询