• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java addition with char  RSS feed

 
Michael rust
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, in my assignment i needed to use charAt to separate the string into 14 parts. Now i need to use addition and add these together.

I have tried many times with no success, every time I add them together and print it out it gives me a number way bigger than it should be.
     


How can i do this?
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael, you need to remember that we can't read what you don't post.  There has to be more details to this. I can probably guess what details you've left out but I'd rather you learn how to write complete posts that don't leave much to other people's imagination so that they can give you precise advice that's based on known information, not guesses.

What kind of characters is this String comprise of? Are they just digits? No non-digit characters? Are you trying to get the sum of all the digits in a number?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also...what are you expecting to see, and what are you actually seeing?
 
Campbell Ritchie
Marshal
Posts: 56521
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to refine the last question: did you expect '1' to map to the number 1?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!