The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Array and loop

Goal: To count the number of times each letter (a-z) is used in a file. The code is workin (atleast it appears to be), but I have a couple issues.

1. I am wanting the array to be initialized in the constructor but when I do that the other methods can't access is. Is there a way to make that work?
2. I am not sure how to reset the counter at the end in the resetInventory method

Re: Array and loop

There are a couple of minor issues.

1. You main method is defined incorrectly, it should be

public static void main(String [] args)

2. Create an instance of the LetterInventory object in the main method and call methods on todhe object. You can initialize the counters in the constructor as all methods of the object will be able to see it.