Home > Back-end >  In Java error: need to 'class' need '; '
In Java error: need to 'class' need '; '

Time:03-08

The original code:
Package com. Itheima. Demo;
Import the Java. Util. Arrays;/* also don't know what is the import role, blind to make no error */
import java.util.Scanner;
import java.util.List;
Import the Java. Util. ArrayList;

Public class HelloWorld {
Public static void main (String [] args) {
PrintL ();
PrintM ();
L printC (int [], int [] M);/* this error!!!!!!!!!!!!!! Java: Java: need to 'class' need '; '*/
}



L/* 1, declare an integer array can be set to 50, and then press the descending order in L as between 1 to 20 in the odd number (only once) are stored in the number of each
2, L put a number 14 in array in the appropriate position, and maintain the decreasing order L
3, put a number 4 in an array of 2nd L (pay attention to the digits are the starting from 0, namely after the operation element is 1 L, 5-tetrafluorobenzoic...).
4, statistical array the number of elements in the deposited */L

Private static int [] printL () {
Int [] L=new int [50].
For (int I=1, j=1; I & lt;=20; I++) {
If (I % 2!=0) {
j++;
L [j]=I;
System. The out. Print (L [j] + "\ t");
}
}
Int len=0;
for(int i=0; iIf (L [I]!=0) {
Len +=1;
}
}

Scanner sc=new Scanner(System.in);
System. The out. Println (" please enter insert data: ");
L [len]=sc. NextInt ();
For (int I=len; I> 0; I -) {
If (L [I] Int temp=L [I];
L=L [I] [I - 1);
L=\ [I - 1];
} else {
break;
}
}
Int index=3;
The int value=https://bbs.csdn.net/topics/4;
Int [] newL=new int [L.l ength + 1];
for (int i=0; iNewL [I]=L [I];
}
For (int I=newL. Length - 1; I> The index; I -) {
NewL [I]=newL [I - 1);
}
NewL [index]=value;
L=newL;
System. The out. Println (Arrays. ToString (L));
Int numL=0;
for(int i=0; iIf (L [I]!=0) {
NumL +=1;
}
}
System. The out. Println (" L the number of elements in the storage array is: "+ numL);
Return the L;
}

M/* 5, declare an integer array can be set to 50, and then press 1 to 20 in the descending order in M between the even number (only once) are stored in the each number */

Private static int [] printM () {
Int [] M=new int [50].
For (int I=1, j=0; I & lt;=20; I++) {
If (I % 2==0) {
j++;
M [j]=I;
System. The out. Print (M [j] + "\ t");
}
}
Return M;
}

/* 6, declare an integer array can put a number 100 C, L and M array elements are stored in an array of C (not C element orderly) */

L private static void printC (int [], int [] M) {
Int [] C=new int [100].
System. Arraycopy (L, 0, C, 0, L.l ength);
System. Arraycopy (M, 0, C, L.l ength + 1, M.l ength);
for(int i=0; i<=C.l ength; I++) {
System. The out. Print (C [I] + "\ t");
}
}
}



/* just refer from C to Java */

CodePudding user response:

PrintC (new int [] {}, new int [] {});/* this error!!!!!!!!!!!!!! Java: Java: need to 'class' need '; '*/
Here is call prontC method need to use the concrete object cannot use the defined parameters
  • Related