Hi Leute, bin ein Java Anfänger und habe ein kleines problemschen, ich hoffe kann mir jemand dabei helfen und dieses Code richtig umstellen. Danke im vorraus
Code:
public class ClassB {
public final byte Nothing = -1;
public int[]myliste= {9,0,9,7,5,1,2,4,9,5};
public ClassB(){
int[]y = go(myliste);
for(int i=0;i<y.length;i++){
System.out.println(":: y["+i+"]= " + y[i]);
}
}
public int[]go(int[]x){
do_operation();
int counter= 0;
for(int i=0; i<x.length;i++)
int y[] = new int[counter];
int j= 0;
for(int i=0; i<x.length;i++){
if(x[i]!=Nothing){
y[j]= x[i]*x[i];
j++;
}
}
return y;
}
private void do_operation(){
int[]x=myliste;
int i=0; int j=i+1;
while(i<x.length){
while(j<x.length){
if(x[i]==x[j])
x[j]=Nothing;
j++;
}
i++;
j=i+1;
}
System.out.print("[do] x[.]= {");
for(i=0; i<x.length; i++){
System.out.print(x[i]);
if(i !=x.length-1)
System.out.print(";");
}
}
System.out.println("}");
}
public static void main(String[] args) {
ClassB gg = new ClassB();
}
}