Ace school

with brainly

  • Get help from millions of students
  • Learn from experts with step-by-step explanations
  • Level-up by helping others

A community for students.

public class tester { int[]alpha= {25,35,45,55}; for(int x= 0; x<=4; x++) System.out.print(alpha[x]+" "); } How can I make it compile?

Computer Science
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SIGN UP FOR FREE
first of all you need to have main method secondly in loop you should stop at element 4, e.g. make x<4 instead of x<=4 because it would be out of bounds
How do you write the main method if alpha was already declared?
I have absolutely no understanding of arrays :(

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

wrap evetyhing to main method
you always have to have main method arrays have nothing to do with it
public class tester { public static void main (String[] args) { int[]alpha= {25,35,45,55}; for(int x= 0; x<4; x++) System.out.print(alpha[x]+" "); } }
OH NO DUH!!!
Thank you so much! I was thinking of object oriented programming and I was really confused
Remove the equal sign from for loop of array, as they are zero-index based. It'll always count a index more than your actual array indexes,if you put equal.

Not the answer you are looking for?

Search for more explanations.

Ask your own question