• Post Reply Bookmark Topic Watch Topic
  • New Topic

string to integer  RSS feed

 
Jay Turner
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The problem is
this "123456123457123458123460123461" number is a string. I must take this string's substrings as six digits. Then, I will control if these numbers' sequential. But, I've been troubling with transform string to integer.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume you know how to get 6‑character substrings from that String. The easiest way to get an int is usually with a method of the Integer class.
 
Jhon Gonzales
Greenhorn
Posts: 22
Java Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
write down your code and the error.
 
Jay Turner
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I presume you know how to get 6‑character substrings from that String. The easiest way to get an int is usually with a method of the Integer class.


Yes, you are right. But, the obligation is that I have to take a string as numbers then, convert it to integer.
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you supposed to do your own parsing? If so, you will need to use old‑fashioned carbon technology rather than silicon: a pencil and paper. Write down how you would turn a String like "123456789" into a number. It is not that complicated, really. I have had to do it in FORTH.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!