Hi, will someone please tell me whats wrong with my java code, im and absolute newb just trying to write a program that works.
As i said, i'm very new to Java. I've learned python before so i know some programming concepts, i'm trying to write a stupid program that kind of mocks shorthand compression. Literally just simulates it. I know that there is a lot of holes in the way this works, but like i said i just want to make something work. Eventually i want the program to read the amount of repeated characters then put that amount as well as the character. For example: If their are 7 0's, print 70. 7 being the amount of the character and 0 being the character. The code: class myCompression { static void alg() { int[] arr = {0,0,0,0,0,0,0}; for(int i: arr) { if (i==0) { int[] data = new int[arr.length]; data[0] = 0; } for(int dat: data) { System.out.println(dat); } } } public static void main(String[] args) { alg(); } } The output: ..\Playground\:10: error: cannot find symbol for(int dat: data) { ^ symbol: variable data location: class myCompression 1 error Thanks for any responses.