Hey all! I'm trying to run a chat application where a client (aside of chatting) can ask to calculate the factorial of a number.
For the number 12, the client types for example "factorial:12"
When I get the numbers I put them into an array and then convert them into a
string, ultimately converting them back into ints,
afterwards which I use to calculate the factorial.
Sadly it's not working out and it's giving me a NumberFormatException at this line:
n = Integer.parseInt(getallen);
Here's the main part of the code:
This is what I can in Eclipse as error:
12Exception in
thread "main" java.lang.NumberFormatException: For input string: "[2]"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at InstantMessagingApplication.ServerApp$HandleAClient.run(ServerApp.java:209)
at InstantMessagingApplication.ServerApp.<init>(ServerApp.java:95)
at InstantMessagingApplication.ServerApp.main(ServerApp.java:32)
Stored array numbers: 1
Stored array numbers: 2
Can anybody help me out on this one?
All suggestions are welcome!
Thanks!