Ive written a small program that reads a text file (whose text is "one" or "two". An instance of a class "number" is updated, and the program is meant to print the text, the line number, and wether the number is odd or even. However the "odd or even" never works, it is always "false", so please help me find where i am going wrong
When your number object is created, the isOdd variable gets a default value of false.
You create your number object with the string representation of the StringTokenizer. That's something like 'java.util.StringTokenizer@XXXXXX' where the XXXXXX part is the hexidecimal representation of the hash code.
You need to create a new number object inside your loop with the result of st.nextToken() instead:
Thanks very much Rob Prime, it works now and i understand how now Out of curiosity, is there a more up-to-date method to achieve the same results (ie to improve speed, accessibility from other classes etc), as im not sure if im using an outdated method. ( No need to rewrite the code if there is a better method, just a "keyname" would be good).