public class arraChange {
public static void main(String []args){
int arr [] = {2,3,4,5,6,7,8};
public class arrayCounter {
public static void main(String args []){
Random rand = new Random();
int freq[] = new int [7];
considering the above two seperate lines of codes, i just want people to explain to me why i can't write:
int arr [] = {2,3,4,5,6,7,8}; // in the first lines like this:
int arr [] = new [2,3,4,5,6,7,8]; // just like the way that in second lines of codes was written
i.e int [] = new int [7];
cos i tried it like that just to try whether it will run too, cos i expect this "[7];" not to be a correct way to end a statement, but from the tutorial i got it, yhe code run fine, so i tried it in that first one to see if it will run too, but it gives error report, so please can anyone explain to me why is like that?
Its just in my quest to understand how java works, pls bear with me