This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am attempting to take a file of numbers of the format:
and place each digit in an array one at a time. I am getting a compile error (3, actually). Could someone help me understand what the errors are referring to? Let me know if you need to see more of my code (the program is a bit long and ugly at the moment).
When I change the expression to read
My errors change to:
File: C:\Users\Jo\Projects\ProjectEuler\PE013.java [line: 36]
Error: C:\Users\Jo\Projects\ProjectEuler\PE013.java:36: incompatible types
found : java.lang.String required: int
File: C:\Users\Jo\Projects\ProjectEuler\PE013.java [line: 69]
Error: C:\Users\Jo\Projects\ProjectEuler\PE013.java:69: int cannot be dereferenced
I'm not sure what's going on with line 69 either, but I don't think it would be related.
Or just use Scanner's nextInt method. As for converting anything to a String, there are a few overloaded static valueOf methods in the String class. You can use those to convert any value, including primitives and null, into Strings.
Joined: Aug 26, 2011
Thanks all! Good suggestions, and now I have it working and understand Java a bit better!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com